473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem while using the bar code reader in a form

115 100+
I have a invoice form that works manually ... I tried to use the bar code reader it didn't work well.
the form contains 12 lines each line is similar of the other one . and contains these unbound text boxes and one combo box.
first i have a combo box named "type" , after that i have the article.txt , and after that the size.txt , after that i got all the descriptions about the price ...
typei , articlei , sizei , .... 1 < i < 12
well when i open the form the cursor is set on the article1.txt ... when i use the bar code to enter the first article ... the article enter correctly without any problem and the cursor is now on article2.txt.
So now i try to enter another article by the bar code reader ... when i use the dar code... here i discover that the combo box type2.txt has erase from his content , while it must stay equal to R by default (typei.txt = R by default). and to enter the article with the bar code reader now i should reenter the value of type2 (that is R by default) and after that press enter to go to set the focus on article2.txt and then i use the bar code reader a second time and now it worked ... but please does any one know why is that happening ? hope that i made it clear to all ! please reply ... many thanks to you guys
Nov 21 '10 #1
45 2942
RuralGuy
375 Expert 256MB
Uhh...clear as mud. Here's a link about name that you should *not* use for objects in your db: http://www.allenbrowne.com/AppIssueBadWord.html You have used some. You may want to describe the issue in slightly different terms for us feeble minded readers. ;)
Nov 22 '10 #2
hannoudw
115 100+
Actually the field name is From "FromR_S" and not "Type"
and i didn't get it !!
these are the names of my fields :
achat_num , article , size , fact_num , quantite_vendu , prix_vente_unitaire , difference , fromR_S.
Nov 23 '10 #3
RuralGuy
375 Expert 256MB
Bar code readers are used on Access applications all of the time. I do not really understand what you are talking about when referring to the ComboBox. Calling a control article.txt confuses me as well. What is the .txt for?
Nov 23 '10 #4
hannoudw
115 100+
Oh sorry it's a text box !! :S My mistake ...
I was reading an article about this problem ....
Nov 23 '10 #5
RuralGuy
375 Expert 256MB
Maybe if you posted a zipped up sample of your db it would be clearer as to what is happening.
Nov 23 '10 #6
hannoudw
115 100+
well it's so big to upload ... I'll try to describe it ...
I have an invoice form , my invoice form is composed of 12 lines all text boxes (Unbound text boxes) .
the thing is when i use the barcode reader to enter the 1st code number (the code number is composed of 2 numbers , the article and the size , code = article concatenate with the size) , but when i want to enter to invoice form , i want to re decompose it into article and size , so first i fill the article , then the size, then all the information about the article will be automatically show in the corresponded combo box (1st price, 2nd price, ...) and after that i did use the Setfocus method to go to the second line and to enter a new code number if i want to . THIS STEP WORK FINE
Then problem is that when i try to enter a new code the information wont enter properly ... is it because that some scanners are pre-programmed to send a Carriage Return which mimics the operator pressing the "Enter" key on the keyboard ... and that's why the focus is now in the second line and i'm not being able to enter the code using the bar code reader anymore ? And if so how can i fix it?
Nov 23 '10 #7
RuralGuy
375 Expert 256MB
Almost *all* scanners can be set to enter a <CR> or not after the scan. At this point I don't know if you need one or not. Can you create a new db and import just this form and whatever associated tables and queries you need? That should be smaller to zip up and upload.
Nov 24 '10 #8
hannoudw
115 100+
how can i upload an attachment here?
Nov 25 '10 #9
hannoudw
115 100+
Ok here's the invoice form that i'm talking about ! thanks for your help !
Attached Files
File Type: zip Database2.zip (161.6 KB, 127 views)
Nov 25 '10 #10
RuralGuy
375 Expert 256MB
Have you tried to Compile this db? I get an error.
Nov 25 '10 #11
RuralGuy
375 Expert 256MB
I'm not going to work on this until you still have a problem after getting this to compile without errors and upload a fresh copy.
Nov 25 '10 #12
hannoudw
115 100+
Yes i did compile it with no errors ...
when you're getting the error? and what's the error?
Nov 25 '10 #13
RuralGuy
375 Expert 256MB
It is this line:
Next intCtrlNo
in the Private Sub Save_Click() procedure in the Fracture form. It is at least out of place in my copy.
Nov 25 '10 #14
RuralGuy
375 Expert 256MB
The error is "Next without For"
Nov 25 '10 #15
hannoudw
115 100+
I tried it again and it's working with no error ... weired!
Nov 25 '10 #16
RuralGuy
375 Expert 256MB
Well if you didn't do anything to make it go away then you will probably not need to do anything to get it back. :D Happy Thanksgiving!
Nov 25 '10 #17
hannoudw
115 100+
it's working but the thing is that it wont work if i use the bar code reader :(
Nov 25 '10 #18
RuralGuy
375 Expert 256MB
I've got mine working without a compile error now so I'll see if I can figure out what is going on. Does your bar Code reader put out a <CR> after the scan? If not, how is it set?
Nov 25 '10 #19
hannoudw
115 100+
yes it seems that the bar code reader put a <CR> after scan. I made the code the article concatenate with the size.
For example 1111111250 , i tried it on the first line it work without error but if i go on the second line and i scan another code it wont work ! even if the code was the same!
Nov 25 '10 #20
hannoudw
115 100+
first i tried this bar code (1111111250) , because i was setting the focus from article to size when the length of the article1 is equal of 7 !
But i found that it just work for the 1st line and it wont work for the 2nd line .
I was using this procedure on the facture form
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Article1_Change()
  3.  
  4.     If (Len(Me.Article1.Text) = 7) Then
  5.         Me.Type1.SetFocus
  6.         If (Not CheckIfExist(CLng(Nz(Me.Article1.Value, 0)))) Then
  7.  
  8.             MsgBox "Article Not Found"
  9.  
  10.         Else
  11.  
  12.            Me.size1.SetFocus
  13.             Dim db As DAO.Database
  14.             Dim Recordset As DAO.Recordset
  15.             Dim Price1, Price2 As Long
  16.  
  17.             Set db = CurrentDb
  18.             Dim Sql As String
  19.  
  20.  
  21.             Sql = "select nz(Price,0) ,nz(Price_after_discount,0) from item where article= " & CLng(Me.Article1.Value)
  22.  
  23.             Set Recordset = DBEngine(0)(0).OpenRecordset(Sql)
  24.  
  25.  
  26.             Me.achat_num1.Value = 1
  27.             Me.quantite_vendu1.Value = 1
  28.  
  29.  
  30.            Price1 = Recordset.Fields(0)
  31.            Price2 = Recordset.Fields(1)
  32.             Me.Price1.Value = Price1 ' you can get the value in this methode without the name of field
  33.             Me.Price_after_discount1.Value = Price2
  34.  
  35.  
  36.             If (Me.Price_after_discount1.Value = 0) Then
  37.                 Me.prix_vente_unitaire1.Value = Price1
  38.                 Me.Difference1.Value = 0
  39.                 Me.totdis1.Value = 0
  40.             Else
  41.                 Me.prix_vente_unitaire1.Value = Price2
  42.                 Me.Difference1.Value = Price1 - Price2
  43.                 Me.totdis1.Value = Price1 - Price2
  44.             End If
  45.             db.Close
  46.             Recordset.Close
  47.  
  48.         End If
  49.     End If
  50. End Sub
  51.  
For that i change it like u have it now ! and i tried to use this code 1111111%M250%M (code 39 "Full ASCII" mode). But it's not working don't know why
Nov 25 '10 #21
RuralGuy
375 Expert 256MB
I've got to ask: why are you using an unbound form? You can see how much extra work you needed to do just to get it working even this much.
Nov 26 '10 #22
hannoudw
115 100+
I really don't remember why i change it to unbound :S
but now it's working in unbound , i don't wanna change it to bound text box ... it just i don't know how can i use the bar code reader without getting error.
Is it wrong to use unbound forms?
Nov 27 '10 #23
RuralGuy
375 Expert 256MB
Access is doing a lot to assist when Bound Forms are used. I have yet to see a situation where an unbound form was necessary. I'll still try and figure out what is going on but it may take time.
Nov 27 '10 #24
RuralGuy
375 Expert 256MB
Your situation lends itself to Bound Forms with the SubForm in Continuous Form mode rather than the multitude of unbound controls that limit the entries in your SubForm. I'm afraid you have me overwhelmed with the mass of duplicate code to handle each control. This feeble mind no longer has the energy to deal with this approach to Object Oriented - Event driven software. I do not know, nor do I care to learn why you are moving the Focus around the form. Let's hope someone with the energy and time to wade in here drops by to assist. I'll see if I can locate someone in the Experts section. Sorry. I feel I would not be doing you a favor in assisting with the further development of such a form.
Nov 27 '10 #25
Lysander
344 Expert 100+
Hi,
Just had a look at your code, unfotunately it is in Access 2010 which I have only just installed and am not familiar with yet. However, your code has an undeclared variable in it.

On Form_Open event you have the following line

newFactNum = maxfactnum + 1

newFactNum is not defined. If you put 'option explict' at the front of each module, it will tell you if you are using undeclared values.

Also in form open, you open a recordset, but never close it again. This could cause problems.

As RuralGuy pointed out, you also have a Next without any For, this also give compile errors.

Sorry I can't offer any positive help but this is seriously the 1st time I have opened Access 2010 and I need to understand the new layout myself first.
Nov 27 '10 #26
MMcCarthy
14,534 Expert Mod 8TB
1. I'm not sure why you are using the On Enter event rather than the After Update or On Change events.
2. If you enter 1111111250, Where exactly are you entering that and how does it get split up into Article and Size?
3. I'm still not sure from what you say if this is working for you if you enter the codes manually and not using the scanner.
Nov 27 '10 #27
MMcCarthy
14,534 Expert Mod 8TB
I've tidied up your code to make it easier for everyone to follow ...
Expand|Select|Wrap|Line Numbers
  1. Private Sub size1_Enter()
  2. Dim db As DAO.Database
  3. Dim rs As DAO.Recordset
  4. Dim strSQL As String
  5.  
  6.     Me.Type1.SetFocus 'why have you set focus here when you change it to size one on line 8
  7.  
  8.     If (Not CheckIfExist(CLng(Nz(Me.Article1.Value, 0)))) Then
  9.         MsgBox "Article Not Found"
  10.     Else
  11.         Me.size1.SetFocus ' what do you set focus here for
  12.  
  13.         strSQL = "select nz(Price,0) as P1, nz(Price_after_discount,0) As P2 from item where article= " & CLng(Nz(Me.Article1.Value, 0))
  14.  
  15.         Set db = CurrentDb
  16.         Set rs = db.OpenRecordset(strSQL)
  17.  
  18.         Me.achat_num1.Value = 1
  19.         Me.quantite_vendu1.Value = 1
  20.  
  21.         Me.Price1.Value = rs!P1
  22.         Me.Price_after_discount1.Value = rs.P2
  23.  
  24.         If (Me.Price_after_discount1.Value = 0) Then
  25.             Me.prix_vente_unitaire1.Value = rs!P1
  26.             Me.Difference1.Value = 0
  27.             Me.totdis1.Value = 0
  28.         Else
  29.             Me.prix_vente_unitaire1.Value = rs.P2
  30.             Me.Difference1.Value = rs!P1 - rs.P2
  31.             Me.totdis1.Value = rs!P1 - rs.P2
  32.         End If
  33.  
  34.         rs.Close
  35.         Set rs = Nothing
  36.         Set db = Nothing
  37.     End If
  38.  
  39. End Sub
  40.  
You will see I also added comments to say I don't know why two lines of code are there. The Me.Type1.SetFocus and the Me.Size1.SetFocus lines don't seem to be doing anything so I'm not sure why they are included.
Nov 27 '10 #28
NeoPa
32,556 Expert Mod 16PB
I put this advice together a while back. It's something that all members should be aware of and follow before asking any questions because, as it says, so many problems are simply a result of not doing so.
It is always a good idea to ensure that variable name checking is enabled, AND your code compiles (at least compilation has been attempted), before submitting a question (Require Variable Declaration).

This avoids asking questions which are much more easily resolved on your own PC than on a forum.

To ensure variable name checking is enabled for all new modules, go to - Tools / Options / Editor (from the VBA Editor window) and set Require Variable Declaration to True (checked). For existing modules, ensure that the Option lines at the very top include :
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
To compile your project, select (again from the VBA Editor window) Debug / Compile Project Name.

We ARE generally happy to help with compilation problems too (If you find an error reported and you can't resolve it, let us know), but we do expect members to have tried compiling before submitting a question. That way we have a better idea of the sort of problem we're looking at.
As RuralGuy says, it is also a bad idea to manipulate data with unbound forms. It's a bit like going into a shop and seeing two of what you want. You ask the shopkeeper the difference and they say They are both free, but if you take the one on the right then I have to slap you in the face. Then selecting the one on the right. You just know it's going to cause you pain, and all for no benefit.
Nov 27 '10 #29
hannoudw
115 100+
To MMcCarthy , if the article number is not correct (if the article does not exist in the table item, i'm setting the focus to Type1, else (if the article is correct) i'm setting the focus on the size to enter the size) and that's why i am using The Me.Type1.SetFocus and the Me.Size1.SetFocus lines.
Nov 27 '10 #30
hannoudw
115 100+
To MMcCarthy.
I tried to use the On Change event without the On Enter event like i said before . And yes it was working manually without using the scanner. (Note that on enter event is working manually ).
when i use the On Change event on the article and another On Lost Focus event on the size, and those 2 events to split the entered bar code 1111111250 into Article and size.And to check if the article number and the size is entered correctly in the form.

And here is the code for the 2 events.
But i thought that it would be better to right it using the On Enter event rather than the On Change event. (because i want to test it to be equal 7 digits and already created in the database, that's mean that it exist in the item table)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Article1_Change()
  2.  
  3.     If (Len(Me.Article1.Text) = 7) Then
  4.         Me.Type1.SetFocus
  5.         If (Not CheckIfExist(CLng(Nz(Me.Article1.Value, 0)))) Then
  6.  
  7.             MsgBox "Article Not Found"
  8.  
  9.         Else
  10.  
  11.            Me.size1.SetFocus
  12.             Dim db As DAO.Database
  13.             Dim Recordset As DAO.Recordset
  14.             Dim Price1, Price2 As Long
  15.  
  16.             Set db = CurrentDb
  17.             Dim Sql As String
  18.  
  19.  
  20.             Sql = "select nz(Price,0) ,nz(Price_after_discount,0) from item where article= " & CLng(Me.Article1.Value)
  21.  
  22.             Set Recordset = DBEngine(0)(0).OpenRecordset(Sql)
  23.  
  24.  
  25.             Me.achat_num1.Value = 1
  26.             Me.quantite_vendu1.Value = 1
  27.  
  28.  
  29.            Price1 = Recordset.Fields(0)
  30.            Price2 = Recordset.Fields(1)
  31.             Me.Price1.Value = Price1 ' you can get the value in this methode without the name of field
  32.             Me.Price_after_discount1.Value = Price2
  33.  
  34.  
  35.             If (Me.Price_after_discount1.Value = 0) Then
  36.                 Me.prix_vente_unitaire1.Value = Price1
  37.                 Me.Difference1.Value = 0
  38.                 Me.totdis1.Value = 0
  39.             Else
  40.                 Me.prix_vente_unitaire1.Value = Price2
  41.                 Me.Difference1.Value = Price1 - Price2
  42.                 Me.totdis1.Value = Price1 - Price2
  43.             End If
  44.             db.Close
  45.             Recordset.Close
  46.  
  47.         End If
  48.     End If
  49. End Sub
  50.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub size1_LostFocus()
  3.    AchatNumValue = CLng(Nz(Me.achat_num1.Value, 0))
  4.    ArticleValue = CLng(Nz(Me.Article1.Value, 0))
  5.    SizeValue = CLng(Nz(Me.size1.Value, 0))
  6.  
  7.   'MsgBox ("article: " & ArticleValue)
  8.   'MsgBox ("size: " & SizeValue)
  9.   'MsgBox ("achatnum: " & AchatNumValue)
  10.  
  11.          article = ArticleValue
  12.          size = CStr(SizeValue)
  13.          'the first digit number of the article
  14.          myfirstdig = Left(article, 1)
  15.        '  MsgBox ("myfirstdig: " & myfirstdig)
  16.          If (myfirstdig = 1) Then
  17.         Select Case Left(article, 1) & "|" & size
  18.          Case "1|170", "1|180", "1|190", "1|200", "1|210", "1|220", "1|230", "1|240", "1|250", "1|260", "1|270", "1|280", "1|290", "1|300"
  19.           'MsgBox ("size true")
  20.            ' If (Len(Me.size1.Text) = 3 And Me.quantite_vendu1.Value = 1) Then
  21.            If (Len(Me.size1.Text) = 3) Then
  22.                Me.Article2.SetFocus
  23.            End If
  24.  
  25.      Case Else
  26.             'MsgBox ("check the size")
  27.             Me.Article1.SetFocus
  28.      End Select
  29.      End If
  30.          If (myfirstdig = 2) Then
  31.         Select Case Left(article, 1) & "|" & size
  32.          Case "2|270", "2|280", "2|290", "2|300", "2|310", "2|320", "2|330", "2|340", "2|350", "2|360", "2|370", "2|380", "2|390", "2|400"
  33.           'MsgBox ("size true")
  34.            ' If (Len(Me.size1.Text) = 3 And Me.quantite_vendu1.Value = 1) Then
  35.            If (Len(Me.size1.Text) = 3) Then
  36.                Me.Article2.SetFocus
  37.            End If
  38.  
  39.      Case Else
  40.             'MsgBox ("check the size")
  41.             Me.Article1.SetFocus
  42.      End Select
  43.      End If
  44.  
  45.            If (myfirstdig = 3 Or myfirstdig = 4 Or myfirstdig = 5 Or myfirstdig = 9) Then
  46.         Select Case Left(article, 1) & "|" & size
  47.          Case "3|350", "3|360", "3|370", "3|380", "3|390", "3|400", "3|410", "3|420", _
  48.          "9|901", "9|902", "9|903", "9|904", "9|905", "9|906", _
  49.          "4|350", "4|360", "4|370", "4|380", "4|390", "4|400", "4|410", "4|420", _
  50.          "5|350", "5|360", "5|370", "5|380", "5|390", "5|400", "5|410", "5|420", _
  51.          "9|100", "9|101", "9|102", "9|104", "9|106", "9|108", "9|110", "9|111", "9|112", "9|114", "9|116"
  52.           'MsgBox ("size true")
  53.            ' If (Len(Me.size1.Text) = 3 And Me.quantite_vendu1.Value = 1) Then
  54.            If (Len(Me.size1.Text) = 3) Then
  55.                Me.Article2.SetFocus
  56.            End If
  57.  
  58.      Case Else
  59.             'MsgBox ("check the size")
  60.             Me.Article1.SetFocus
  61.      End Select
  62.      End If
  63.  
  64.               If (myfirstdig = 7) Then
  65.         Select Case Left(article, 1) & "|" & size
  66.          Case "7|390", "7|400", "7|405", "7|410", "7|415", "7|420", "7|425", "7|430", "7|435", "7|440", "7|445", "7|450", "7|460", "7|470"
  67.           'MsgBox ("size true")
  68.            ' If (Len(Me.size1.Text) = 3 And Me.quantite_vendu1.Value = 1) Then
  69.            If (Len(Me.size1.Text) = 3) Then
  70.                Me.Article2.SetFocus
  71.            End If
  72.  
  73.      Case Else
  74.             'MsgBox ("check the size")
  75.             Me.Article1.SetFocus
  76.      End Select
  77.      End If
  78.  
  79.  
  80.               If (myfirstdig = 6 Or myfirstdig = 8) Then
  81.         Select Case Left(article, 1) & "|" & size
  82.          Case "6|350", "8|350"
  83.           'MsgBox ("size true")
  84.            ' If (Len(Me.size1.Text) = 3 And Me.quantite_vendu1.Value = 1) Then
  85.            If (Len(Me.size1.Text) = 3) Then
  86.                Me.Article2.SetFocus
  87.            End If
  88.  
  89.      Case Else
  90.             'MsgBox ("check the size")
  91.             Me.Article1.SetFocus
  92.      End Select
  93.      End If
  94.  
  95. End Sub
  96.  
Note : I used the myfirstdig to retrieve the 1st digit of the article because i'm working on a Invoice for a shoes shop and they have for every serial number a different sizes . Like if the article start with 1 he can just have those sizes 17,18,19....,to 30 and i added the zero at the end of every size cause i have half sizes and i want to represent them for example: 41.5 --> 405
so the sizes will be 170,180,190,.... ,to 300

Hope that i made it clear for you !

But the thing is that if i use the On Enter event. I need to put a <CR> after the article and after the size , and i tried this bar code "1111111%M250%M" but it's not working when scanning , I was trying to use the code 39 in Full ASCII mode like it said in this site (http://http://www.carolinabarcode.co...tion-a-74.html) but it didn't worked!
Nov 27 '10 #31
hannoudw
115 100+
To RuralGuy Thanks a lot for your time and your help :)
Nov 27 '10 #32
RuralGuy
375 Expert 256MB
You are welcome.
Nov 27 '10 #33
hannoudw
115 100+
And all of you guys MMcCarthy and NeoPa thanks :)
Nov 27 '10 #34
hannoudw
115 100+
To NeoPa
I went to Tools / Options and like you said i just select Require Variable Declaration from the Editor tab. And after that i pressed on form view and i test it and i got the facture form working without errors!
Nov 27 '10 #35
NeoPa
32,556 Expert Mod 16PB
HannoudW:
I went to Tools / Options and like you said i just select Require Variable Declaration from the Editor tab.
Very pleased to hear it. This should prove helpful in all your projects :-)
Nov 27 '10 #36
hannoudw
115 100+
Thanks a lot but still i am wondering how can i make this barcode work?
1111111$M250$M as this example "http://http://www.carolinabarcode.co...tion-a-74.html"
Nov 27 '10 #37
NeoPa
32,556 Expert Mod 16PB
I don't propose to get into the details of your current setup. Frankly I believe you are creating some of your own problems by deciding to use unbound forms for your proposed solution.

What I will do though, is suggest a way to deal with the bar code reader generally.
  1. Find out what you can from the web site. As mentioned earlier, they normally behave like a keyboard only they enter a bunch of characters in quick succsession.
  2. Find out the options there are for configuring what is returned in the way of characters to your application. If you want a Carriage Return and/or Line Feed sent, then configure it that way (assuming the options are there of course).
  3. Play with it on its own. Set up a noddy form and find out exactly what it sends. Each character code sent etc. Know your appliance before you ever try to use it in an already complex situation.
  4. When you know what you're dealing with then set it up to work in your more complicated form. If that is an unbound form, then only you have to worry about the problems involved with that. Your choice. Your responsibility.

I hope these pointers can help you find your way.
Nov 27 '10 #38
hannoudw
115 100+
Thanks NeoPa ... Well i'll do my best and i'll create a new form just for testing, a small one ! :)
Nov 27 '10 #39
NeoPa
32,556 Expert Mod 16PB
Potentially useful events to play with might be Form_KeyPress or, for the TextBox control, _Change or _KeyPress. Have a play and see what gives you the information you need at the most helpful speed (character by character hopefully).
Nov 27 '10 #40
hannoudw
115 100+
Your right in On Enter event i'm getting what i want but i have a speed problem ! Can i make it the event when i press the <Enter> from the keyboard? if so how can i do that ?
Nov 27 '10 #41
NeoPa
32,556 Expert Mod 16PB
What did you find when you tried the events I suggested? I suspect you will need more precise information than what On Enter will give you. That won't answer the most obvious question of what is included as well as the basic data. EG. is there a CR and/or a LF added at the end.
Nov 27 '10 #42
hannoudw
115 100+
I don't know how to use the _KeyPress event ...
it's like that Private Sub Article1_KeyPress(KeyAscii As Integer)
but can i precise here that the key pressed is the Enter?
Nov 27 '10 #43
hannoudw
115 100+
I did tried this event and it's faster
Expand|Select|Wrap|Line Numbers
  1. Private Sub Article1_Change()
  2.     If (Len(Me.Article1.Text) = 7) Then
  3.         Me.Type1.SetFocus
  4.         If (Not CheckIfExist(CLng(Nz(Me.Article1.Value, 0)))) Then
  5.  
  6.             MsgBox "Article Not Found"
  7.  
  8.         Else
  9.  
  10.            Me.size1.SetFocus
  11.             Dim db As DAO.Database
  12.             Dim Recordset As DAO.Recordset
  13.             Dim Price1, Price2 As Long
  14.  
  15.             Set db = CurrentDb
  16.             Dim Sql As String
  17.  
  18.  
  19.             Sql = "select nz(Price,0) ,nz(Price_after_discount,0) from item where article= " & CLng(Me.Article1.Value)
  20.  
  21.             Set Recordset = DBEngine(0)(0).OpenRecordset(Sql)
  22.  
  23.  
  24.             Me.achat_num1.Value = 1
  25.             Me.quantite_vendu1.Value = 1
  26.  
  27.  
  28.            Price1 = Recordset.Fields(0)
  29.            Price2 = Recordset.Fields(1)
  30.             Me.Price1.Value = Price1 ' you can get the value in this methode without the name of field
  31.             Me.Price_after_discount1.Value = Price2
  32.  
  33.  
  34.             If (Me.Price_after_discount1.Value = 0) Then
  35.                 Me.prix_vente_unitaire1.Value = Price1
  36.                 Me.Difference1.Value = 0
  37.                 Me.totdis1.Value = 0
  38.             Else
  39.                 Me.prix_vente_unitaire1.Value = Price2
  40.                 Me.Difference1.Value = Price1 - Price2
  41.                 Me.totdis1.Value = Price1 - Price2
  42.             End If
  43.             db.Close
  44.             Recordset.Close
  45.  
  46.         End If
  47.     End If
  48. End Sub
  49.  
But the problem is that the article is composed from 7 digit so if i enter in the article text box less or more than 7 digit i can't handle it .. to get error .
like i can't write like this in the On Change event
Expand|Select|Wrap|Line Numbers
  1.  
  2. If (Len(Me.Article1.Text) < 7 Or Len(Me.Article1.Text) > 7) Then
  3.         MsgBox "Article Not Found"
  4.         Me.Type1.SetFocus
  5.         End If
  6.  
That's why i found it better to use the On Enter event .
Nov 27 '10 #44
hannoudw
115 100+
I didn't get this line (EG. is there a CR and/or a LF added at the end.) !!
At the end of what ?
I just wanna write an event to be lunched when i click the enter key on the keyboard ....
For example if i was on article and i press on Enter is it possible to write these kind of events in vba?
Nov 27 '10 #45
NeoPa
32,556 Expert Mod 16PB
I don't know what you're saying, and your code is missing the most important line - the one at the top which tells me which procedure it is and which event it's handling.

Normally, when you enter data in somewhere you enter all the individual characters, then you enter a Carriage Return (The enter key) - often abbreviated to CR. The ASCII code for this is 13 decimal or 0D hexadecimal.

To be able to be used in systems designed for keyboadrd entry, the bar code readers often send data that includes a CR at the end, so as to tell whatever software that is reading the data, that it has finished its entry. These devices are often configurable as different software needs/requires different ways to indicate that it's finished on a particular entry. This you need to find out.

The dummy/test form gives you a means to determine this if you look at the values passed to the event procedure when using the device. I'm not sure what more I can say to simplify this, but if you have any specific questions that I can understand I will happily try.
Nov 28 '10 #46

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: pmud | last post by:
I have an application (ASP.Net using C# ) . I need to read records from the database based on the value entered by the user. Using Data Reader , I can see only one record in text boxes. But how do...
1
by: Andrew K | last post by:
Hi, This is a problem I noticed in one of my applications the other day and can't figure out how to fix. In the attached code I have 2 forms. The form named form1 is the MDI container, form2...
0
by: No bother | last post by:
The record source for a form I use is based on a query, which has several layers of subqueries with quite a number of joins. Needless to say this record source is not updateble. However, the data...
0
by: TCook | last post by:
Hey All, I'm trapping a 'submit' button's 'Click' event in a VB.Net code behind class in order to loop through a 'Select' controls 'option' list as follows: For Each ThisItem In...
3
by: Franky | last post by:
Been having a problem using a treeview. Work great the first time the form containing it is entered but not the second time. Took a while to create a small sample that exhibits the problem, but...
4
hariharanmca
by: hariharanmca | last post by:
How can I get Bar-Codes from Bar-Code Reader through VB Coding. Where it will store the Bar-Code Value.
4
by: hendafe | last post by:
I have a point of sales application I developed in Access, but the owner requires a Bar Code Reader. Is it possible to configure it with Access. I have no idea and this is causing stress in...
2
by: sacha4 | last post by:
I need to make an edit page using data reader. this is my code.. Sub Page_Load() If Not IsPostBack Then Dim conn As SqlConnection Dim cmdSQL As SqlCommand ...
1
by: blessonin | last post by:
hi all, i want to know how to read the content of a http posted file using stream reader i am using the folloing line but an error in the last line sayin that " 'System.IO.Stream' cannot be...
1
by: yatindra | last post by:
Hi, i am doing purchase module in a inventory control system. in that module i want to use bar code to read the barcode from lebel which is on the product. i have taken a text box and now i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.