am new on VB6 and would like your urgent help, i have created my POS half way and have created a form for sales, now what i want is when i enter an item code all the other information related to the item diplays at the respective text boxes..
hi johnly, i did exactly like how instructed and it worked very well.. but this does not allow me to enter the item code myself and retrieve the data associated to the item code.when i run the form, it automatically fills the areas with the data.
what i want is when i enter the item code, it matches with the one in the database and then retrieve the rest of the data associated to that item code.
for example, when i enter 2000 in the item code area, it matches that one with the one in my database and return the price, item name and tax associated to that item in the respective areas
Only problem with that johnly is using the change event of the textbox. As the lookup code (number/alpha) gets longer your code will be executed each time there is a change! Which means for a four digit code, your code will pound the datbase four times with your look up query! Better to put the actual search under a command button (or perhaps the lost focus event of the text box if you want a high amount of automation).
sackymatt,
Have you even tried the Data Form Wizard and see what code it generates for you?
Thanx guys again, i really appreciate your time in this forum..
Fistly Jonhly, i tried the code in the txtcode box and when i run the form and try to enter the item code (barcode) a 'run time error '424' object required' keeps on popping up.
I also tried it in a command button, still the same error pops up.
in debug mode, it highlights the following
<code>
Private Sub txtcode_Change() Data1.RecordSource = "select * from items where barcode = " & Val(txtcode.Text)
Data1.Refresh
End Sub
</code>
Does this have to do with the connection maybe? i have my database on ms access though.
vb5prgrmr,
How do i use Data Form Wizard? Please elaborate more if possible,
Thanx
Start a new standard exe project>vb's ide menu>Add-Ins>Add-In Manager.
Hightlight VB 6 Data Form Wizard
Lower right corner of form where frame with caption says Load Behavior put a check in the box next to Loaded/Unloaded>click Ok
Add-Ins>Data Form Wizard
Follow wizard enough times to get every combination of form type along with code/class/control.
Save project for future reference.
1. Is the name of your search textbox is (where you are entering the barcode) txtCode ?
2. Is the name of your data control is Data1 ?
3. The RecordsetType property of the data control should not be 0 - Table. It can be 1 - Dynaset or 2 - Snapshot.
You can have it as 2 - snapshot if you do not want to edit the values, and just want to view it.
I agree with Vb5Prgmr that there is a performance issue if you call the code in the change event of the textbox. Instead you can write this code in the click event of a commandbutton.
You can write the code in change event if you require the values to get automatically loaded in the textboxes when you type the code in the search textbox. But the other method (using a button) is preferrable if the table contains a large number of records.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.