On Error GoTo Err_insertbtn_Click
()
Should not have the parenthesis after click
and
These are Labels and REQUIRE a colon at the end for the "On Error GoTo Err_insertbtn_Click" statement to function.
Code:
Exit_insertbtn_Click:
Exit Sub
Err_insertbtn_Click:
What is
Returned_Mail.Medicaid_ID
It looks like a "TableName.FieldName". I asked (twice) what the names of the controls are because you are getting the values from the CONTROLS, not fields in a table.
Since the controls are on the same form where the code is, you can use the "Me" shortcut to refer to "Forms!FormName".
When yo create a bound control on a form, Access tries to be helpful and names the control the same name as the field; it gets confusing sometimes. I always rename the control by adding a prefix or suffix. If the control is unbound, say a text box, then it gets named "Text10" or a button "Command9". Not very descriptive. Again I take the time to give meaningful names to the controls.
Back to your code problem. If the name of the CONTROL is "Medicaid_ID", use "Me.Medicaid_ID". (same for the other two controls)
Code:
sSQL = sSQL & " VALUES ('" & Me.Medicaid_ID & "', #" & Me.CalDueDate & "#, #" & Me.CAQH_Notifification & "#);"
Code:
Private Sub insertbtn_Click()
On Error GoTo Err_insertbtn_Click
Dim sSQL As String
Dim DueDate As Date
Forms!RA_Processing.SetFocus
DoCmd.GoToControl "Medicaid_ID"
'delete data in table
'CurrentDb.Execute "DELETE * FROM MergeData;", dbFailOnError
'insert new record
sSQL = "INSERT INTO MergeData (Medicaid_ID, DueDate, CAQH_Notification)"
sSQL = sSQL & " VALUES ('" & Me.Medicaid_ID & "', #" & Me.CalDueDate & "#, #" & Me.CAQH_Notifification & "#);"
(I am getting a Object defined error on this line. What am I missing?)
CurrentDb.Execute sSQL, dbFailOnError
Exit_insertbtn_Click:
Exit Sub
Err_insertbtn_Click:
MsgBox Err.Description
Resume Exit_btn60_Click
End Sub
Code:
Forms!RA_Processing.SetFocus
DoCmd.GoToControl "Medicaid_ID"
I don't understand why you have these two lines.
The form already is active (has the focus).
And to set the focus to a control, use
Code:
Me.Medicaid_ID.SetFocus
Or maybe I just don't understand the problem..........