Hi guys!
I have another problem
I have a two tables called "Data" and "Import" and a form called "Form_MappingTables".
In this form I have two dropdown lists: Address1 and Address2.
These are lists of fields from table "Import".
I'm trying to write a function that inserts these two fields data into Data table.
So, user will pick from dropdowns fields (Source_Address1 and Source_Address2) then clicks a button run run macro, which runs this function.
It supposed to insert data from Import.Add1 and Import.Add2 by using field names from form dropdowns.
I hope this makes sense.
I get error:"Error updating: Access database engine cannot find the input table or query 'Form_MappingTables'..."
Here is my code...
I know I messed it up, but trying to simply use those dropdown from form to define which fields should be used to insert.
Please help!
I have another problem
I have a two tables called "Data" and "Import" and a form called "Form_MappingTables".
In this form I have two dropdown lists: Address1 and Address2.
These are lists of fields from table "Import".
I'm trying to write a function that inserts these two fields data into Data table.
So, user will pick from dropdowns fields (Source_Address1 and Source_Address2) then clicks a button run run macro, which runs this function.
It supposed to insert data from Import.Add1 and Import.Add2 by using field names from form dropdowns.
I hope this makes sense.
I get error:"Error updating: Access database engine cannot find the input table or query 'Form_MappingTables'..."
Here is my code...
Code:
Public Function MappingForm() As Boolean
On Error Resume Next
Dim ws As Workspace
Dim db As DAO.Database
Dim strSQL As String
Dim tbl As String
Dim frm As String
Dim Form_MappingTables As Form
Set ws = DBEngine.Workspaces(0)
Set db = ws.Databases(0)
tbl = "Data"
frm = "Form_MappingTables"
On Error GoTo Proc_Err
'start a transaction to ensure all updates are run or rolled back
ws.BeginTrans
strSQL = "INSERT INTO [" & tbl & "] ( Address1, Address2 ) SELECT [" & frm & "].Source_Address1,[" & frm & "].Source_Address2 FROM [" & frm & "]"
db.Execute strSQL, dbFailOnError
'commit all changes
ws.CommitTrans
Proc_Exit:
Set ws = Nothing
Set db = Nothing
Exit Function
Proc_Err:
ws.Rollback
MsgBox "Error updating: " & Err.Description
Resume Proc_Exit
End Function
I know I messed it up, but trying to simply use those dropdown from form to define which fields should be used to insert.
Please help!