[RESOLVED] Runtime Error '3001': Invalid Argument
Code:
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSAVE_Click()
Dim ask As String
Set DB = OpenDatabase(App.Path & "\Database\products.mdb")
DB.Execute "Insert into Inventory([Number],[Name],[Price],[Quantity],[Vendor],[Description])values(" & "'" & txtNumber & "'" & "," & "'" & txtName & "'" & "," & "'" & txtPrice & "'" & "," & "'" & txtQuantity & "'" & "," & "'" & txtVendor & "'" & "," & "'" & txtDescription & "'" & ")"
DB.Close
MsgBox "Saved"
txtNumber = ""
txtName = ""
txtPrice = ""
txtQuantity = ""
txtVendor = ""
txtDescrip = ""
End Sub
Private Sub cmdSEARCH_Click()
Dim ask As String
Set DB = OpenDatabase(App.Path & "\Database\Products.mdb")
i = "select*from Inventory where Number='" & txtNumber & "'"
Set Rec = DB.OpenRecordset(i, dbOpenSnapshot)
If Rec.EOF = False Then
ask = MsgBox("record found")
txtNumber = Rec!Number
txtName = Rec!Name
txtPrice = Rec!Price
txtQuantity = Rec!Quantity
txtVendor = Rec!Vendor
txtDescrip = Rec!Description
DB.Close
Else
ask = MsgBox("record not found")
txtNumber = ""
txtName = ""
txtPrice = ""
txtQuantity = ""
txtVendor = ""
txtDescrip = ""
End If
End Sub
Private Sub Form_Load()
Call Grid_Click
Call LoadRec
End Sub
Private Sub LoadRec()
Dim Y As String
Dim Rowcount As Integer
Rowcount = 1
Set DB = OpenDatabase(App.Path & "\Database\Products.mdb")
Y = "select * from Inventory number <> 'a'"
Set Rec = DB.OpenRecordset(Y, dbOpenSnaphot)
If Rec.EOF = False Then
Rec.MoveNext
Do While Not Rec.EOF
If Rowcount >= 6 Then
Grid.Rows = Grid.Rows + 1
End If
Grid.TextMatrix(Rowcount, 1) = Rec!Number
Grid.TextMatrix(Rowcount, 2) = Rec!Name
Grid.TextMatrix(Rowcount, 3) = Rec!Price
Grid.TextMatrix(Rowcount, 4) = Rec!Quantity
Grid.TextMatrix(Rowcount, 5) = Rec!Vendor
Grid.TextMatrix(Rowcount, 6) = Rec!Description
Rowcount = Rowcount + 1
Rec.MoveNext
Loop
DB.Close
End If
End Sub
Private Sub Grid_Click()
Grid.Clear
Grid.Rows = 6
Grid.ColWidth(0) = 2000
Grid.ColWidth(1) = 2000
Grid.ColWidth(2) = 2000
Grid.ColWidth(3) = 2000
Grid.ColWidth(4) = 2000
Grid.ColWidth(5) = 2000
Grid.TextMatrix(0, 0) = "Number"
Grid.TextMatrix(0, 1) = "Name"
Grid.TextMatrix(0, 2) = "Price"
Grid.TextMatrix(0, 3) = "Quantity"
Grid.TextMatrix(0, 4) = "Vendor"
Grid.TextMatrix(0, 5) = "Description"
End Sub
What's this error?
Re: Runtime Error '3001': Invalid Argument
Your SQL doesn't look right, shouldn't you have 'WHERE' in it?
Code:
Y = "SELECT * from Inventory WHERE number <> 'a'"
Re: Runtime Error '3001': Invalid Argument
so I added where but still I get the error 3001 in
Code:
Set Rec = Db.Openrecords (Y, dbopensnapshot)
Re: Runtime Error '3001': Invalid Argument
If i delete Call LoadRec from Private Sub Form_Load()
the error dissappears But I cant see my Database Records inside the flexgrid.
Re: Runtime Error '3001': Invalid Argument
I solved it. It was some code Miscapitalised.
so the code was dbopensnapshot to dbOpenSnapshot.