Bar Code Application

  • Thread starter Fakhruddin Zavery
  • Start date
F

Fakhruddin Zavery

Hello,

Has anyone tried using a bar code scanner kind of application using MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com
 
B

Bogdan Zamfir

Hello,
Has anyone tried using a bar code scanner kind of application using MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Basically, there are two kind of bar code readers. First of them works on
keyboard interface. They connect to the kb in on the mainboard and offers
another kb type connector, just to connect your regular keyboard.

When you scan a code, the computer think it was typed at the keyboard (so
you can use it to scan in every textbox field. Also, after finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of the following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc. The code
basically will read the value from the textbox, and then perform the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using various
approaches (using API to access the COM port, using some AxtiveX lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
 
F

Fakhruddin Zavery

Thanks Bogdan,

I have just tried out a simple test. I have a table that is storing item
name, price and the barcode, I am using a simple form to enter values in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead and
looks for that Item but if my first field to display from the query was name
then it BLANKS it out .... It puts empty spaces and tries to overide by
database value with nothing.

Any Help will be appreciated.

Bogdan Zamfir said:
Hello,
Has anyone tried using a bar code scanner kind of application using MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Basically, there are two kind of bar code readers. First of them works on
keyboard interface. They connect to the kb in on the mainboard and offers
another kb type connector, just to connect your regular keyboard.

When you scan a code, the computer think it was typed at the keyboard (so
you can use it to scan in every textbox field. Also, after finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of the following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc. The code
basically will read the value from the textbox, and then perform the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using various
approaches (using API to access the COM port, using some AxtiveX lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
 
B

Bogdan Zamfir

Hi,
I have just tried out a simple test. I have a table that is storing item
name, price and the barcode, I am using a simple form to enter values in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead and
looks for that Item but if my first field to display from the query was name
then it BLANKS it out .... It puts empty spaces and tries to overide by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode field.

You might also want to use unbound fields, so if the code isn't found in the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left txtName and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer

 
F

Fakhruddin Zavery

Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Bogdan Zamfir said:
Hi,
I have just tried out a simple test. I have a table that is storing item
name, price and the barcode, I am using a simple form to enter values in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead and
looks for that Item but if my first field to display from the query was name
then it BLANKS it out .... It puts empty spaces and tries to overide by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode field.

You might also want to use unbound fields, so if the code isn't found in the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left txtName and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan
 
B

Bogdan Zamfir

Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error on?

Bogdan



Fakhruddin Zavery said:
Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Bogdan Zamfir said:
Hi,
I have just tried out a simple test. I have a table that is storing item
name, price and the barcode, I am using a simple form to enter values in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead and
looks for that Item but if my first field to display from the query
was
name
then it BLANKS it out .... It puts empty spaces and tries to overide by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode field.

You might also want to use unbound fields, so if the code isn't found in the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left txtName and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer

Hello,

Has anyone tried using a bar code scanner kind of application
using
MS works
on keyboard
(so
using
 
T

Thomas Lutz

For reading bar codes into an Access application, you have two
choices.
Most bar code readers are available with one of two output options.
The first option is called "Keyboard Wedge" output where you unplug
your keyboard, plug the bar code reader into the keyboard port on your
PC and then plug your keyboard into the bar code reader. This
arrangement makes the bar code reader appear as it it were simply a
second keyboard. Your original keyboard continues to work as normal
however when you read a bar code, the data encoded in the bar code
appears to any application running on your PC as if it were typed in.
The keyboard wedge interface is extremely simple however it has a few
drawbacks. If you swipe a bar code, the cursor has to be in the
correct input field in the correct application otherwise you end up
reading bar code data into whatever application has the focus. This
can cause all sorts of potential problems as you can imagine. The
keyboard output also is limited in that you cannot modify the data in
any way before sending it into the program that is to receive the
data. For example, if you needed to parse a bar code message up into
pieces or remove some of a bar code message or add in a date or time
stamp you would not be able to with a normal keyboard wedge reader.

The other possible output option is to get a bar code reader with an
RS232 or "Serial" interface. With these types of bar code readers, you
connect the reader to an available serial port on the back of your PC.
You would then need a program called a "Software Wedge" to take the
data from the bar code reader and feed it to the application where you
want the data to go. The disadvantage to this approach is that it is a
little more complex however you gain much more control over how and
where your data ends up when you read a bar code. With a Software
Wedge, you can control exactly where the data goes in the target
application and you can also perform all sorts of modifications on the
data before it is sent to the application.

TAL Tehchnologies sells a product called WinWedge which is a Software
Wedge for Windows. Visit: http://www.taltech.com for more information.

This web site is also an extremely good place to obtain information
about bar coding in general.

For printing bar codes from Access, you would be best off using a bar
code ActiveX control like the one fromTAL Technologies at the
following URL:
http://www.taltech.com/products/activex_barcodes.html

I would recommend that you download the demo of the TAL Bar Code
ActiveX control from the above URL and take a look at the sample
Access database that is provide with the demo.
 
F

Fakhruddin Zavery

Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Bogdan Zamfir said:
Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error on?

Bogdan



Fakhruddin Zavery said:
Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error with
type mismatch.
I used the second code in your instruction. Used the unbound idea.
values
in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead and
looks for that Item but if my first field to display from the query was
name
then it BLANKS it out .... It puts empty spaces and tries to overide by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode field.

You might also want to use unbound fields, so if the code isn't found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left
txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Basically, there are two kind of bar code readers. First of them works
on
keyboard interface. They connect to the kb in on the mainboard and
offers
another kb type connector, just to connect your regular keyboard.

When you scan a code, the computer think it was typed at the keyboard
(so
you can use it to scan in every textbox field. Also, after finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc. The code
basically will read the value from the textbox, and then perform the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using various
approaches (using API to access the COM port, using some AxtiveX lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 
B

Bogdan Zamfir

How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Fakhruddin Zavery said:
Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Bogdan Zamfir said:
Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error on?

Bogdan



storing
item values ahead
and query
was overide
by
found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application using
MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Basically, there are two kind of bar code readers. First of them works
on
keyboard interface. They connect to the kb in on the mainboard and
offers
another kb type connector, just to connect your regular keyboard.

When you scan a code, the computer think it was typed at the keyboard
(so
you can use it to scan in every textbox field. Also, after finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc. The code
basically will read the value from the textbox, and then perform the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using various
approaches (using API to access the COM port, using some AxtiveX lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
Hello,

Has anyone tried using a bar code scanner kind of application using
MS
Access? If so will appreciate some ideas and tips on how to go about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 
F

Fakhruddin Zavery

BarCode is defined as Text

Bogdan Zamfir said:
How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Fakhruddin Zavery said:
Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Bogdan Zamfir said:
Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error on?

Bogdan



Thanks Bogdan,

I tried out your instructions and I seem to be getting run time
error
with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Hi,

I have just tried out a simple test. I have a table that is storing
item
name, price and the barcode, I am using a simple form to enter values
in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead
and
looks for that Item but if my first field to display from the query
was
name
then it BLANKS it out .... It puts empty spaces and tries to overide
by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table
name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode field.

You might also want to use unbound fields, so if the code isn't
found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how to go
about
creating one.

Basically, there are two kind of bar code readers. First of them
works
on
keyboard interface. They connect to the kb in on the mainboard and
offers
another kb type connector, just to connect your regular keyboard.

When you scan a code, the computer think it was typed at the
keyboard
(so
you can use it to scan in every textbox field. Also, after finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc.
The
code
basically will read the value from the textbox, and then
perform
the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using various
approaches (using API to access the COM port, using some AxtiveX
lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how to go
about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 
B

Bogdan Zamfir

And what error number do you get?

Bogdan


Fakhruddin Zavery said:
BarCode is defined as Text

Bogdan Zamfir said:
How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Fakhruddin Zavery said:
Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from
OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error on?

Bogdan



Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error
with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Hi,

I have just tried out a simple test. I have a table that is storing
item
name, price and the barcode, I am using a simple form to enter
values
in
them. I type the name and price and scan the barcode. It works fine.

However when I try to serach for a item using a Query it goes ahead
and
looks for that Item but if my first field to display from the query
was
name
then it BLANKS it out .... It puts empty spaces and tries to overide
by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table
name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table,
and
left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode
field.

You might also want to use unbound fields, so if the code isn't found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left
txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how
to
go mainboard
and
to
 
F

Fakhruddin Zavery

It says Run Time Error 13 - Type Mismatch

Bogdan Zamfir said:
And what error number do you get?

Bogdan


Fakhruddin Zavery said:
BarCode is defined as Text

Bogdan Zamfir said:
How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from
OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime
error
on?
Bogdan



Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error
with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Hi,

I have just tried out a simple test. I have a table that is
storing
item
name, price and the barcode, I am using a simple form to enter
values
in
them. I type the name and price and scan the barcode. It works
fine.

However when I try to serach for a item using a Query it goes
ahead
and
looks for that Item but if my first field to display from the
query
was
name
then it BLANKS it out .... It puts empty spaces and tries to
overide
by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table
name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and
left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode
field.

You might also want to use unbound fields, so if the code isn't
found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left
txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from
YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how
to
go
about
creating one.

Basically, there are two kind of bar code readers. First
of
them
works
on
keyboard interface. They connect to the kb in on the mainboard
and
offers
another kb type connector, just to connect your regular
keyboard.

When you scan a code, the computer think it was typed at the
keyboard
(so
you can use it to scan in every textbox field. Also, after
finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some
of
the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit,
etc.
The
code
basically will read the value from the textbox, and then perform
the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using
various
approaches (using API to access the COM port, using some AxtiveX
lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
message
Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how
to
go
about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 
B

Bogdan Zamfir

Hi,

This is quite strange.
Do you have set reference to DAO? You should also uncheck reference to ADO,
if you have it. Or if you have to keep them both, use this code:

dim rs as DAO.Recordset

Try to add following lines at the begining of the AfterUpdate sub

dim db as DAO.database
set db = curentdb
set rs = db.OpenRecordset(....)

Bogdan





Fakhruddin Zavery said:
It says Run Time Error 13 - Type Mismatch

Bogdan Zamfir said:
And what error number do you get?

Bogdan


Fakhruddin Zavery said:
BarCode is defined as Text

How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from
OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime error
on?

Bogdan



Thanks Bogdan,

I tried out your instructions and I seem to be getting run time
error
with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Hi,

I have just tried out a simple test. I have a table that is
storing
item
name, price and the barcode, I am using a simple form to enter
values
in
them. I type the name and price and scan the barcode. It works
fine.

However when I try to serach for a item using a Query it goes
ahead
and
looks for that Item but if my first field to display from the
query
was
name
then it BLANKS it out .... It puts empty spaces and tries to
overide
by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items
table
name,
and add three textbox controls to it, txtCode, txtName and
txtPrice
Bind txtName and txtPrice to appropriate fields in the
table,
and
left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode
field.

You might also want to use unbound fields, so if the code isn't
found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left
txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from
YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of
application
using
MS
Access? If so will appreciate some ideas and tips on
how
to
go
about
creating one.

Basically, there are two kind of bar code readers. First of
them
works
on
keyboard interface. They connect to the kb in on the mainboard
and
offers
another kb type connector, just to connect your regular
keyboard.

When you scan a code, the computer think it was typed at the
keyboard
(so
you can use it to scan in every textbox field. Also, after
finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some of
the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit, etc.
The
code
basically will read the value from the textbox, and then
perform
the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using
various
approaches (using API to access the COM port, using some
AxtiveX
lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
message
Hello,

Has anyone tried using a bar code scanner kind of
application
using
MS
Access? If so will appreciate some ideas and tips on
how
to
go
about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 
F

Fakhruddin Zavery

It says Run Time Error 13 - Type Mismatch

Bogdan Zamfir said:
And what error number do you get?

Bogdan


Fakhruddin Zavery said:
BarCode is defined as Text

Bogdan Zamfir said:
How barcode is defined?
For my code to work, I made the assumption Barcode field should be defined
as text.
If it is number, change the code as below:

Set rs = CurrentDb.OpenRecordset("select Name, Price from Inventory where
BarCode = " & Me.txtCode)

HTH,
Bogdan

___________________________
Freelance programmer


Hello Bogdan,

I must thank you for the help you are giving to me ... Thank You.

I get the error on this line:- Set rs = CurrentDb.OpenRecordset("select
Name, Price from Inventory where BarCode = '" & Me.txtCode & "'")

I have defined my BarCode Filed as a text however the price is a numeric
field and Name is a text field. Hope this helps you.

Thanks

Hi,

On what line did you get runtime error?
It might be with the ProductCode type
I made the assumption you defined it as string type
If you defined it as number, you shold remove apostrophes from
OpenRecordser
SQL statement.

If there is another case, what is the line you get the runtime
error
on?
Bogdan



Thanks Bogdan,

I tried out your instructions and I seem to be getting run time error
with
type mismatch.
I used the second code in your instruction. Used the unbound idea.


Hi,

I have just tried out a simple test. I have a table that is
storing
item
name, price and the barcode, I am using a simple form to enter
values
in
them. I type the name and price and scan the barcode. It works
fine.

However when I try to serach for a item using a Query it goes
ahead
and
looks for that Item but if my first field to display from the
query
was
name
then it BLANKS it out .... It puts empty spaces and tries to
overide
by
database value with nothing.

Any Help will be appreciated.

If you tell me exactly how you did this, I might help.
However you might use the following approach:

Create a new form, set its RecordSource property to the items table
name,
and add three textbox controls to it, txtCode, txtName and txtPrice
Bind txtName and txtPrice to appropriate fields in the table, and
left
txtCode unbound

Then, in the AfterUpdate event of txtCode add the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = Me.RecordsetClone ' (1*)
rs.FindFirst "ProdID='" & Me.txtCode & "'"
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark ' (2*)
Else
MsgBox "This product doesn't exist in database!"
End If
Set rs = Nothing
End Sub

You just have to change the ProdID with the real name of barcode
field.

You might also want to use unbound fields, so if the code isn't
found
in
the
database, to make txtName and txtPrice empty.
To do this, just left the Recordsource for the form empty, left
txtName
and
txtPrice unbound, and use the following code:

Private Sub txtCode_AfterUpdate()
Dim rs As Recordset, bm
Set rs = currentdb.OpenRecordset("select * from
YourItemsTableName
where
ProdID='" & me.txtCode & "'")
if rs.recordcount >0 then
me.txtName = rs![NameProdField]
me.txtPrice = rs![PriceProdField]
Else
MsgBox "This product doesn't exist in database!"
me.txtName = null
me.txtPrice = null
End If
Set rs = Nothing
End Sub

HTH,
Bogdan

-----------------------------------
Freelance programmer



Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how
to
go
about
creating one.

Basically, there are two kind of bar code readers. First
of
them
works
on
keyboard interface. They connect to the kb in on the mainboard
and
offers
another kb type connector, just to connect your regular
keyboard.

When you scan a code, the computer think it was typed at the
keyboard
(so
you can use it to scan in every textbox field. Also, after
finishing
scanning, it also send <Enter> key code.

To interface with it, you should write some code in some
of
the
following
events : AfterUpdate, BeforeUpdate, LostFocus, OnExit,
etc.
The
code
basically will read the value from the textbox, and then perform
the
required search.

Another type of barcode readers uses serial interface (RS232)

To work with them, you need to work with the COM port, using
various
approaches (using API to access the COM port, using some AxtiveX
lime
MSCOMM.OCX, etc)

HTH,
Bogdan Zamfir

______________________________
Freelance developer
message
Hello,

Has anyone tried using a bar code scanner kind of application
using
MS
Access? If so will appreciate some ideas and tips on how
to
go
about
creating one.

Thanks and Regards

--
Fakhruddin Zavery
Sr. Systems Analyst / Programmer
CATS Tanzania Ltd.
NIC Life House 4th Floor
P. O. Box 2569, Dar es Salaam, Tanzania
Tel. +255-22 2137915, 2112631
Fax +255-22 2113033, 2112916
Mob +255 744 277452
website: http://www.catsgroup.com

--------------------------------------------------------------------------
--
---
The Irony of Life is that, no one gets out of it Alive
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top