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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting information into an access database

Status
Not open for further replies.

RadioX

IS-IT--Management
May 15, 2001
145
US
I have a VB form where when the user clicks a button I want it to insert certain data from the form into a database. How would I go about doing this. Here is how my database is setup

tblLog
fldID (primary key, autonumber)
flddate (automatic using date())
fldTimeIn
fldTimeOut

I want to insert fldtime in on a click of one button and fldtimeout on a click of another button. I am using a timer control called txtTimer to get the time.

Thanks for your help or suggestions in advance
 
Dim SQL As String

SQL = "INSERT INTO tablename (tablefieldname) VALUES ('"
SQL = SQL & fldtime & "')"
DatabaseObject.Execute SQL
 
I get a 424 error when I use that script. Here is what to code looks like


Private Sub cmdPunchIn_Click()
Dim SQL As String
Dim strTime As String
txtClock.Text = strTime
Dim strEmpId As String
lblEmpID.Caption = strEmpId
SQL = "INSERT INTO tablename (tablefieldname) VALUES ('"
SQL = SQL & fldtime & "')"
DatabaseObject.Execute SQL


End Sub
 
DatabaseObject.Execute SQL
is what it highlights in yellow

THanks
Ron
 
Right before the execute statement,
put in msgbox that displays SQL,
and see if you can spot an error
in the string.
Also check if SQL is reserved. Jim

oracle, vb
 
I put in the msgbox function and it comes up and says false when I click the button. Here is the code below again. I am still getting a 424 Object Required error.

Thanks for everyones help in this matter

Ron

Private Sub cmdPunchIn_Click()
Dim cmdTime As String
Dim strTime As String
txtClock.Text = strTime
Dim strEmpId As String
lblEmpID.Caption = strEmpId

cmdTime = "INSERT INTO tblLog (fldempid, fldclockin) VALUES (strEmpId, strTime )"

DatabaseObject.Execute cmdTime


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top