access vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Access VBA

Access VBA

resolvedResolved · Low Priority · Version 2007

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

Wed 6 Jun 2012: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Add current time to a field

Press CTRL+SHIFT+ SEMICOLON

View all Access hints and tips


Server loaded in 0.07 secs.