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

Insert Into Doesnt Insert

Status
Not open for further replies.

etjohnson81

Programmer
Jul 17, 2006
72
US
Hello...

I am using the following code to insert a record, the variables are filling ok, but no records get inserted.


Code:
Dim db As DAO.Database
      
    Dim strUsername As String
    Dim strSerial As String
    
    Dim intTech As Integer
    
    strUsername = Forms!frmcomputerassign!cboUsername.Column(1)
    strSerial = Forms!frmcomputerassign!cboSerial.Column(0)
    
    intTech = Forms!frmcomputerassign!cboTech.Column(1)
    
        
    Set db = DBEngine(0)(0)
    db.Execute "INSERT INTO dbo_tblComputerAssignmentHistory (txtUsername,numAssignedBy,dDateAssigned,txtSerial) VALUES ('" & strUsername & "'," & intTech & "," & Date & ", '" & strSerial & "' )"
    msgbox db.RecordsAffected & " computer assigned."
    
    Set db = Nothing

 
try

db.Execute "INSERT INTO dbo_tblComputerAssignmentHistory (txtUsername,numAssignedBy,dDateAssigned,txtSerial) VALUES ('" & strUsername & "'," & intTech & ",#" & Date & "#, '" & strSerial & "' )
 
Replace this:
Code:
& "," & Date & ", '" &
with this:
Code:
& ",#" & Format(Date, "yyyy-mm-dd") & "#, '" &

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top