Here's my code. Now, nothing is happening at all. I've checked the table
and there's no new records. Did I use the insert statement correctly?
____________________________________________________________
On Error GoTo Err_cmdAdd_Click
If IsNull(Me.cboBillets) Then
Exit Sub
Else
CurrentProject.Connection.Execute ("INSERT INTO tblBilletsJoin
(ClearanceNum,BilletNum) " & _
"SELECT tblBilletsJoin.ClearanceNum, tblBilletsJoin.BilletNum FROM
tblBilletsJoin " & _
"WHERE tblBilletsJoin.ClearanceNum = " & Me.ClearanceNum & " AND
tblBilletsJoin.BilletNum = " & Me.cboBillets & ";")
Me.lstBillet.Requery
End If
Exit_cmdAdd_Click:
Exit Sub
Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click
__________________________________________________________________
Do I need to include the semicolon at the end of my sql statement? I don't
remember if I have to if I'm doing it through code.
I just changed the code to the following and it still isn't doing anything.
It's not even giving me an error message.
On Error GoTo Err_cmdAdd_Click
If IsNull(Me.cboBillets) Then
Exit Sub
Else
Dim strSQL As String
strSQL = "INSERT INTO tblBilletsJoin (EmpNum,BilletNum) " & _
"SELECT tblBilletsJoin.EmpNum, tblBilletsJoin.BilletNum FROM tblBilletsJoin
" & _
"WHERE tblBilletsJoin.EmpNum = " & Me.EmpNum & " AND
tblBilletsJoin.BilletNum = " & Me.cboBillets & ";"
CurrentProject.Connection.Execute strSQL
Me.lstBillet.Requery
End If
Exit_cmdAdd_Click:
Exit Sub
Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click
> Here's my code. Now, nothing is happening at all. I've checked the table
> and there's no new records. Did I use the insert statement correctly?
[quoted text clipped - 59 lines]
> > >
> > > I might be totally confusing myself. I don't know.
Jonathan Brown - 30 Jan 2008 22:22 GMT
> I just changed the code to the following and it still isn't doing anything.
> It's not even giving me an error message.
[quoted text clipped - 89 lines]
> > > >
> > > > I might be totally confusing myself. I don't know.
mscertified - 31 Jan 2008 15:36 GMT
The code looks ok as far as I can tell.
Use standard debugging techniques...
Display the SQL statement before it executes.
Try running the SQL standalone as a query.
Try using DEBUG to step thru the code to see what is happening.
You will learn far more by debugging this yourself that by getting a canned
answer.
-Dorian
> I just changed the code to the following and it still isn't doing anything.
> It's not even giving me an error message.
[quoted text clipped - 89 lines]
> > > >
> > > > I might be totally confusing myself. I don't know.