B
Bonnie
Hi there! Using A02 on XP. Not a programmer but love learning this. Have a
form with a record showing the contract number in a text field [RunThisOne].
First button imports a file into a table and names it
[Forms]![fCensus1Conversion]![RunThisOne]&"Copy". So my new table would be
named GP0013Copy. A few of the records may have a [Status Code] of "T"
(Terminated). I've created a DELETE query to remove the terminated records
from the table GP0013Copy before exporting again. Now I need to create some
VB to change my source for the query. I may have contract number GP0013 or
GP1992, etc. on the form. I need to delete the [Status Code] = T records in
the table named for the contract number on my form. I've altered some code
given to me for a project something like this. But, I'm getting an error:
Run-time error '3075': Syntax error (missing operator) in query expression
'IIf((GP0013Copy![Status Code])='T', GP0013Copy.[Status Code], FROM
GP0013CopyWITH OWNERACCESS OPTION;'
Private Sub Command39_Click()
Dim strSQL As String
Dim dbsCurrent As Database
Dim qryClean As QueryDef
Set dbsCurrent = CurrentDb
strSQL = "SELECT "
strSQL = strSQL & "IIf((" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Copy![Status Code])= 'T', "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy.[Status
Code], "
strSQL = strSQL & " FROM "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy"
strSQL = strSQL & "WITH OWNERACCESS OPTION;"
'MsgBox strSQL
'the name of your query goes in here
Set qryClean = dbsCurrent.QueryDefs("qClearTermsCensus1")
qryClean.SQL = strSQL
Set dbsCurrent = Nothing
Set qryClean = Nothing
End Sub
It seems like it should work but I'm sure I missed something. I would
appreciate any help or advice. Thanks!
form with a record showing the contract number in a text field [RunThisOne].
First button imports a file into a table and names it
[Forms]![fCensus1Conversion]![RunThisOne]&"Copy". So my new table would be
named GP0013Copy. A few of the records may have a [Status Code] of "T"
(Terminated). I've created a DELETE query to remove the terminated records
from the table GP0013Copy before exporting again. Now I need to create some
VB to change my source for the query. I may have contract number GP0013 or
GP1992, etc. on the form. I need to delete the [Status Code] = T records in
the table named for the contract number on my form. I've altered some code
given to me for a project something like this. But, I'm getting an error:
Run-time error '3075': Syntax error (missing operator) in query expression
'IIf((GP0013Copy![Status Code])='T', GP0013Copy.[Status Code], FROM
GP0013CopyWITH OWNERACCESS OPTION;'
Private Sub Command39_Click()
Dim strSQL As String
Dim dbsCurrent As Database
Dim qryClean As QueryDef
Set dbsCurrent = CurrentDb
strSQL = "SELECT "
strSQL = strSQL & "IIf((" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Copy![Status Code])= 'T', "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy.[Status
Code], "
strSQL = strSQL & " FROM "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy"
strSQL = strSQL & "WITH OWNERACCESS OPTION;"
'MsgBox strSQL
'the name of your query goes in here
Set qryClean = dbsCurrent.QueryDefs("qClearTermsCensus1")
qryClean.SQL = strSQL
Set dbsCurrent = Nothing
Set qryClean = Nothing
End Sub
It seems like it should work but I'm sure I missed something. I would
appreciate any help or advice. Thanks!