Louise has attended:
Access Advanced course
Access VBA course
Excel Pivot Tables course
Access VBA
Hi
I am trying to take one field from a form and populate a different table with it. I think the error is coming from the set rsttable but I can't see what I've done wrong. Can you help me???
Dim dbData As DAO.Database
Dim rstTable As DAO.Recordset
Dim strsql As String
Set dbData = CurrentDb()
Set rstTable = dbData.OpenRecordset([Tbl Date])
strsql = "INSERT INTO Tbl Date ([sunhsno]) VALUES (" & Me.SUNHSNo.Value & ")"
DoCmd.RunSQL strsql
RE: Access VBA
Hi Louise, thanks for your query. Capture the field from the form in a variable as follows:
myVariable = txtMyFormField
Then concatenate myVariable into the SQL for an Update query and voila!
Hope this helps,
Anthony