| | |
Retrieve POS data
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 17
Reputation:
Solved Threads: 4
Place a data control on the form
Set the database and recordsource propery of the data control
Then place the text boxes to display the values.
Select the datasource property of each text box and set it to the data control.
Now set the datafield property of each textbox to the desired field name.
Set the database and recordsource propery of the data control
Then place the text boxes to display the values.
Select the datasource property of each text box and set it to the data control.
Now set the datafield property of each textbox to the desired field name.
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
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
Any further assistance will be appreciated
Sacky
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
Any further assistance will be appreciated
Sacky
•
•
Join Date: Nov 2008
Posts: 17
Reputation:
Solved Threads: 4
Gr8...
For this you can add a new textbox called (txtItemCode). dont link it with the data control.
Now you can write the following code in the change event of this new textbox.
If the item code data type is text then you can write:
Private Sub txtItemCode_Change()
Data1.RecordSource = "select * from table1 where itemcode = '" & txtItemCode.Text & "'"
Data1.Refresh
End Sub
or if the datatype of the code in database is number the you can write the below
Private Sub txtItemCode_Change()
Data1.RecordSource = "select * from table1 where itemcode = " & val(txtItemCode.Text)
Data1.Refresh
End Sub
Pls note that you need to replace the table name (table1) and fieldname (itemcode) with the actual tablename and field name in your database.
For this you can add a new textbox called (txtItemCode). dont link it with the data control.
Now you can write the following code in the change event of this new textbox.
If the item code data type is text then you can write:
Private Sub txtItemCode_Change()
Data1.RecordSource = "select * from table1 where itemcode = '" & txtItemCode.Text & "'"
Data1.Refresh
End Sub
or if the datatype of the code in database is number the you can write the below
Private Sub txtItemCode_Change()
Data1.RecordSource = "select * from table1 where itemcode = " & val(txtItemCode.Text)
Data1.Refresh
End Sub
Pls note that you need to replace the table name (table1) and fieldname (itemcode) with the actual tablename and field name in your database.
•
•
Join Date: Mar 2009
Posts: 835
Reputation:
Solved Threads: 152
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?
Good Luck
sackymatt,
Have you even tried the Data Form Wizard and see what code it generates for you?
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Mar 2009
Posts: 835
Reputation:
Solved Threads: 152
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.
Good Luck
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.
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
•
•
Join Date: Nov 2008
Posts: 17
Reputation:
Solved Threads: 4
Hi sackymatt,
Please check the following.
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.
Please check the following.
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.
![]() |
Similar Threads
- How to retrieve binary data from string (Java)
- How to make query to retrieve first,last,next,Preivius data from databse (Oracle)
- SELECT and RETRIEVE MYsql Data... (PHP)
- Retrieve data from SQLDataSource (ASP.NET)
- How do I retrieve data from my Crashed Hard Disk? (Windows NT / 2000 / XP)
- How can i retrieve data after i logod on..... (ASP.NET)
- Retrieve the data from the url api (RSS, Web Services and SOAP)
- Login and retrieve user data from database (ASP.NET)
- please help! this is urgent> how to retrieve data to my tabpage without using data fo (C#)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Data report Printing Problem
- Next Thread: Passing argument in a property explanation
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





