CODE 2 ADD RECORD

  • Thread starter Faraz Ahmed Qureshi
  • Start date
F

Faraz Ahmed Qureshi

Could someone pls provide a sample code for BUTTON1 on FORM1 which onclick
adds the entries in TEXTBOX1, TEXTBOX2, TEXTBOX3, TEXTBOX4 to TABLE1's
FIELD1, FIELD2, FIELD3 & FIELD4?
 
F

Faraz Ahmed Qureshi

John Vinson's

Private Sub BUTTON1_Click()
Dim strSQL As String
On Error GoTo Proc_Err
strSQL = "INSERT INTO mytablename (FIELD1, FIELD2, FIELD3, FIELD4) " _
& "VALUES(""" & Me!TEXTBOX1 & """, """ & Me!TEXTBOX2 & _
""", """ & Me!TEXTBOX3 & """, """ & Me!TEXTBOX4 & """);"
Currentdb.Execute strSQL, dbFailOnError
Proc_Exit:
Exit Sub
Proc_Err:
MsgBox "Error " & Err.Number & " in BUTTON1_Click" & vbCrLf & Err.Description
Resume Proc_Exit
End Sub

DID IT!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top