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

Checking a field in a form.

Status
Not open for further replies.

Aerowolf

Programmer
Nov 6, 2002
64
Here's the code I've got:

Private Sub Command13_Click()
DoCmd.OpenTable "WalMartOrderImport"
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.Close
DoCmd.TransferText , "WalMartOrderImportSpec", "WalMartOrderImport", "P:\Edwin\Excel\walmart order export.csv"
DoCmd.OpenForm "WalMartOrderImport"
DoCmd.SelectObject acForm, "WalMartOrderImport"
If InStr([STORE], "#") = 0 Then
[Number] = Val([STORE])
Else
[Number] = Val(Mid([STORE], InStr([STORE]+1, "#"), 4))
End If

End Sub

In the line "If InStr([STORE], "#") = 0", I'm getting the error that it can't find the field [STORE].

Why?

Thanks

Edwin
 
If STORE is Null, I believe this will fail.
Try this:
If InStr(nz([STORE],0), "#") = 0
[Number] = Val(nz([STORE],0))

This will return 0 when STORE is null. Thus it won't fail.

I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Anyway you may replace this:
DoCmd.OpenTable "WalMartOrderImport"
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.Close
By this:
DoCmd.RunSQL "DELETE FROM WalMartOrderImport"
Or by this:
CurrenDB.Execute "DELETE FROM WalMartOrderImport"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top