PDA

View Full Version : Visual basic ask question 2010


rmmal
Sep 14, 2010, 02:20 AM
Hi. How can I perform search on 'item below re order level' my VB, which was connected to Access? What are the codes? Thank you.

Dim Result As String
search = "[Quantity in Stock]" < "[Reorder Level]"
With Product.Recordset
.MoveFirst
.Find Result
If .EOF Then
MoveFirst
MsgBox "Not found."
End If
End With

Ps: the codes above don't work.Error seems to occur on the codes which are bold. Help
Ms.RMMAL.US

GaryStaunton
Nov 23, 2010, 08:08 PM
I'm not surprised that you get an error. Do a little research on SQL queries, for example:

search = "SELECT * FROM TableName WHERE [Quantity in Stock] < [Reorder Level]"

Then apply this SQL query to an intialised recordset, which you haven't done in the code, so maybe research this topic too. A little reading will give you lots of knowledge. There isn't enough room on this page to teach you database access and SQL queries.

ScottGem
Nov 23, 2010, 08:19 PM
Are you writing this code in a VBA module within Access or using VB.Net?

There are several things wrong with that code, but without knowing the platform we can't advise how to fix it.