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

Can't Comprehend Error Message 2

Status
Not open for further replies.

missymarie1014

Technical User
Mar 15, 2007
50
US
I have the following code isolated in the Exit event of a form control, and it is producing the following error message....

The Microsoft Jet database engine cannot find the input table or query 'False'. Make sure it exists and that its name is spelled correctly.

Here is the code.....

Code:
Dim CurDB As Database
Dim rs As recordset
Dim Resp As Integer

Set CurDB = CurrentDb

Set rs = CurDB.OpenRecordset("SELECT * from ItemTable WHERE" & _
Item = Me.ItemUsed)

If rs.RecordCount = 0 Then
    rs.Close
    Set rs = Nothing
    Else
    rs.MoveFirst
    Do Until rs.EOF
        If rs!QuantityOnHand = 0 And rs!CurrentCost = 0 Then
            Resp = MsgBox("This Batch Template Contains Items With Zero Quantity On Hand And Zero Cost!" _
            & vbCrLf & vbCrLf & "Receipt Or Production Of These Items Is Required" _
            & vbCrLf & vbCrLf & "To Insure That Accurate Costs Are Being Maintained", _
            vbOKOnly + vbCritical, "Template Contains Items With Zero Quantity And Zero Cost!")
            Exit Sub
            Exit Do
            Else
        End If
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
End If

I can't seem to make sense of the reference to "False". It produces the same error in the After Update event for the control. Can someone give me some assistance with this and tell me what it means? Thanks very much!
 
I expect the issue is with
Code:
Set rs = CurDB.OpenRecordset("SELECT * from ItemTable WHERE" & _
Item = Me.ItemUsed)
This expression [blue][tt]Item = Me.ItemUsed[/tt][/blue] is evaluating to either true or false.
Try this assuming Item is numeric:
Code:
Set rs = CurDB.OpenRecordset("SELECT * from ItemTable WHERE " & _
"[Item] = " & Me.ItemUsed)

Try this if Item is Text:
Code:
Set rs = CurDB.OpenRecordset("SELECT * from ItemTable WHERE " & _
"[Item] = """ & Me.ItemUsed & """")


Duane
Hook'D on Access
MS Access MVP
 
Thank you dhookom! As a followup to this, I have established a string variable with a value which I would like to appear as part of an on screen message using the MsgBox method. Could you tell me the syntax to get the value of that variable to print along with the rest of the message. Assume the message line is this....

Code:
Resp2 = MsgBox("<string variable here> Was Not Added To This Batch!", vbOKOnly + vbCritical, "Item Not Added To Batch!")
 
Concatenate it into the string, something like the below (with or without CR/LF...)

[tt]Dim TheMessage As String

TheMessage = "Just testing"

Resp2 = MsgBox(TheMessage & " Was Not Added To This Batch!", vbOKOnly + vbCritical, "Item Not Added To Batch!")[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top