B
Bonnie
Hi everyone! Using A02 on XP. Not a programmer, but loving learning.
I have a form that imports a .txt file and then pulls few bells and blows a
few whistles to spit out a .xls file to send to a client. Each table is
named the contract number that has been selected on the form. Next I need to
delete records that meet certain criteria ([StatusCode]="T" and [StatusDate]
is less then [PYB]. PYB is an unbound field that you can type any date into.
Here's my code:
Private Sub Command44_Click()
If IsNull(Me.PYB) Then
MsgBox "You must have a Plan Year Beginning date keyed in. Click
the arrow to copy in the data from the calculated field."
Exit Sub
Else
On Error GoTo ErrHandler
Dim sqlStmt As String
sqlStmt = "DELETE * " & _
"FROM " & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy " & _
"WHERE ([STATUSCODE] = 'T') AND ([STATUSDATE]
<[Forms]![fCensus1Conversion]![PYB])" & _
" WITH OWNERACCESS OPTION;"
Debug.Print "*" & sqlStmt & "*"
CurrentDb().Execute sqlStmt, dbFailOnError
MsgBox "You have deleted records with a Status Code of T and a
Status Date greater than 500 days."
End If
Exit Sub
I get this error: Error in Command44_Click() in fCensus1Conversion form.
Error #3061. Too few parameters. Expected 1.
On the Debug.Print I get this: *DELETE * FROM GP2473Copy WHERE
([STATUSCODE] = 'T') AND ([STATUSDATE] <[Forms]![fCensus1Conversion]![PYB])
WITH OWNERACCESS OPTION;*
I've made sure that my cursor leaves the field but not sure why it's not
working. Any suggestions or advice? Thanks very much in advance for taking
time to read this.
I have a form that imports a .txt file and then pulls few bells and blows a
few whistles to spit out a .xls file to send to a client. Each table is
named the contract number that has been selected on the form. Next I need to
delete records that meet certain criteria ([StatusCode]="T" and [StatusDate]
is less then [PYB]. PYB is an unbound field that you can type any date into.
Here's my code:
Private Sub Command44_Click()
If IsNull(Me.PYB) Then
MsgBox "You must have a Plan Year Beginning date keyed in. Click
the arrow to copy in the data from the calculated field."
Exit Sub
Else
On Error GoTo ErrHandler
Dim sqlStmt As String
sqlStmt = "DELETE * " & _
"FROM " & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy " & _
"WHERE ([STATUSCODE] = 'T') AND ([STATUSDATE]
<[Forms]![fCensus1Conversion]![PYB])" & _
" WITH OWNERACCESS OPTION;"
Debug.Print "*" & sqlStmt & "*"
CurrentDb().Execute sqlStmt, dbFailOnError
MsgBox "You have deleted records with a Status Code of T and a
Status Date greater than 500 days."
End If
Exit Sub
I get this error: Error in Command44_Click() in fCensus1Conversion form.
Error #3061. Too few parameters. Expected 1.
On the Debug.Print I get this: *DELETE * FROM GP2473Copy WHERE
([STATUSCODE] = 'T') AND ([STATUSDATE] <[Forms]![fCensus1Conversion]![PYB])
WITH OWNERACCESS OPTION;*
I've made sure that my cursor leaves the field but not sure why it's not
working. Any suggestions or advice? Thanks very much in advance for taking
time to read this.