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?
Sure... but that's a Really Bad Way to do things, unless you have some very
specific reasons to do so. Why not just use a bound form?
Select the button's Click event; click the ... icon by it and choose Code
Builder. I'll assume that the four fields are of Text datatype (see below).
Edit the code to
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