|
Thanks to everyone for their previous help, I'm almost finished with my
database. I just need one piece of information, and it should be good
to go!
I'm using a SQL Server database with Access 2003 as a frontend. I have
a button on a form that says "Add Record". When the user clicks that, I
would like to have some fields automatically generated so that I don't
get an error that the main database can't accept null entries. Here's
what I have so far:
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
Dim sSQL As String
strSQL = "INSERT INTO <Print Jobs> (<NetworkUser>, <MachineName>,
<ProcessName>, <PrinterName>,) VALUES (<Public Rec>, <Server>,
<MSACCESS.EXE>, <MainPrinter>)"
db.Execute strSQL, dbFailOnError
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
When I run it, it says that an object is required. I'm still new to
VBA, so I don't know what I'm doing wrong as what I have up there was
cobbled from various Usenet posts.
Also, I'd like to enter the date in a date field automatically at the
time of the button press (dd/mm/yy hh:mm:ss). Do I have to do something
different as it's not just straight text like enclosing it in single
quotes?
Thanks for your help! |