PDA

Click to See Complete Forum and Search --> : Probably an Easy Question on Invoice # Loading


airbaal
Oct 5th, 2000, 07:20 PM
I am new to VB 6.0 Enterprise after recently switching over from FileMaker because a) I was extremely limited on what I could do with FMPro and b) I much prefer using VB or C++ than FMPro scripts. I am setting up a database with the DataEnvironment and am having a little trouble viewing a customized set of records within a database table.

I have a database connection setup where VB sees all of the records in the table. However, in this one table, I could have 100 records that deal with invoice #100, and 20 records that deal with invoice #101. I am having a hard time coding it so the user can say, “Load Invoice #101” and only the 20 records are loaded.

I was hoping I could just do some sort of SQL statement where it would say:

SELECT invoice, part, retail FROM tblInvoices WHERE invoice=101

but I can’t figure out how to get around not hardcoding in the 101. I would like the user to be able to input 101 into a form layout’s text box and then after clicking a button, it calls the SQL script or ADO script.

I am still unfamiliar with how VB, ADO, and SQL exactly work together.

If I can’t view just certain records from a table, I guess I have to figure out ways to dynamically create new tables every time a new invoice # is created?

Does anyone have any suggestions?

THANK YOU in advance :-)

-Eric Baal

shragel
Oct 5th, 2000, 11:27 PM
Try

dim InvN as string
InvN = Text1.text ' or the name of your input textbox
..("Select * From Table Where InvnRecord = '" & InvN & "';")



Feel Free To email me at Shragel@YAHOO.COM

HunterMcCray
Oct 6th, 2000, 02:06 PM
Originally posted by shragel
Try

dim InvN as string
InvN = Text1.text ' or the name of your input textbox
..("Select * From Table Where InvnRecord = '" & InvN & "';")



Feel Free To email me at Shragel@YAHOO.COM

This solution assumes that InvnRecord is a text field. If it is a number field leave out the single quotes ('). Secondly it is always best to use Chr(34) if there is any chance that the string field will contain a single quote. When developing an App that uses SQL to sort user generated text fields you either need to test all fields going into the database for single quotes or you need to use double quotes in your SQL statements (ie Chr(34)). I have learned this lesson the hard way. Users love to use things like "Molly's...." in descriptions, and then when they go to sort for it using the single quote and the App crashes. Very Bad.

Hunter