Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro error

Status
Not open for further replies.

SimRick

Technical User
May 2, 2001
21
US
I have a database that uses macros that open forms. One one specific form I get a message that network access was interrupted. I'm sure that it isn't t the network because it only, and always, happens with this form.
Thanks for reading this,
Rick

It is a simple macro:
Option Compare Database

Private Sub Form_AfterUpdate()

End Sub

Private Sub Name_AfterUpdate()
Dim SQL As String


End Sub

Private Sub Save_employee_Click()
On Error GoTo Err_Save_employee_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_employee_Click:
Exit Sub

Err_Save_employee_Click:
MsgBox Err.Description
Resume Exit_Save_employee_Click
Dim SQL As String
SQL = "INSERT INTO secure (name ) " & _
"SELECT '" & Me!Name & "' AS XferName;"
DoCmd.RunSQL SQL

Dim SQL As String
SQL = "INSERT INTO secure (DOB) " & _
"SELECT '" & Me!DOBdate & "' AS XferName;"
DoCmd.RunSQL SQL

End Sub
 
Have you attempted to use a breakpoint and step through your code? I don't know how/when the bottom section of your code will ever run the SQL. If you want the code to run, I would at least use:
Code:
Dim SQL As String
SQL = "INSERT INTO secure ([name] ) " & _
   "Values ('" & Me!Name & "')"
Currentdb.Execute SQL, dbFailOnError

Dim SQL As String
SQL = "INSERT INTO secure (DOB) " & _
   "Values ('" & Me!DOBdate & "')"
Currentdb.Execute SQL, dbFailOnError

Name is a reserved word and should never be used as an object/field name. Your code also assumes DOB is a text field.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top