I am brand new to this forum and pretty new to access. I have everything working except I can't figure out how to get access VBA to write values to my table.
Table name: tblECN
Variable in table that I would like to write a value for: Customer
I have been scavenging the interweb in hopes of finding help with no avail so far. Here is my code:
Private Sub chkCustomerAff_Click()
Dim CustName As String
'Dim strSQL As String
'Dim db As DAO.Database
'Set db = CurrentDb
'Dim rstblECN As DAO.Recordset
Dim rstblECN As Object
'Set rstblECN = CurrentDb.OpenRecordset("Select * From Demographics Where False")
CustName = InputBox("Customer name: ", "Customer Name", "Customer")
If CustName <> "" And CustName <> "Customer" Then
lblCustomer.Caption = CustName
'strSQL="UPDATE tblECN SET Customer= '"&CustName&"' WHERE Customer=CustName"
With rstblECN
.Fields.Item("Customer") = CustName
End With
End If
End Sub
Sorry there are a lot of quoted out lines (I struggled with it for a while before giving up). Any help would be greatly appreciated.