ba1959nh Level: Scholar
 Registered: 10-05-2006 Posts: 39
|
How do I store form data to db?
I have an Access 2003 Form using VB. This Form contains all of the data for a *new* Supporter Record for my Supporters db table. I have code to assign the data in the Form's controls into appropriate VB variables (strings, integers) and have confirmed that the assignments work when I click my SAVE button.
I am now trying to write this new record to the db. I have constructed an INSERT INTO command string (strSQL), but do NOT know how to make the command EXECUTE from inside my VB StoreSupporterData function.
Private Sub fnSaveSupporterRecord()
Dim sSupporterName As String
Dim sOranizationName As String
Dim sAddr1 As String
Dim sAddr2 As String
Dim sCity As String
Dim sState As String
Dim sZip As String
Dim sPhone As String
Dim sFax As String
Dim sEmail As String
Dim sWebsite As String
Dim intOrgType As Integer
Dim intSupporterType As Integer
Dim intSupporterLevel As Integer
Dim intAGWTMembershipID As Integer
Dim bActive As Boolean
Dim sNotes As String
sSupporterName = txtSupporterName
sOranizationName = txtOrganizationName
sAddr1 = txtAddr1
sAddr2 = txtAddr2
sCity = txtCity
sState = ComboState
sZip = txtZip
sPhone = txtPhone
sFax = txtFax
sEmail = txtEmail
sWebsite = txtWebSite
intOrgType = ComboOrgType
intSupporterType = ComboSupporterType
intSupporterLevel = ComboSupporterLevel
intAGWTMembershipID = 0
bActive = true
sNotes = txtNotes
sSQLcmd = "INSERT INTO Supporters (SupporterName, Company_Org_Name, Addr1, Addr2, City, State, Zip, Phone, Fax, Email, WebSite, OrgType, SupporterType, SupporterLevel, AGWTMembershipID, Active, Notes) VALUES ('" & sSupporterName & "', '" & sOranizationName & "', '" & sAddr1 & "', '" & sAddr2 & "', '" & sCity & "', '" & sState & "', '" & sZip & "', '" & sPhone & "', '" & sFax & "', '" & sEmail & "', '" & sWebsite & "', '" & intOrgType & "', '" & intSupporterType & "', '" & intSupporterLevel & "', '" & intAGWTMembershipID & "', '" & bActive & "', '" & sNotes & "');"
' COMMENT - How do I execute this sql comand
End Sub
I appreciate any help.
Thanks,
Bill
[Edited by ba1959nh on 15-05-2006 at 05:09 AM GMT]
|