AUTO TAB IN MS ACCESS

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc used Ask the Experts™
on
I think this could the last part of  my journey in the point of sales (POS) ,all I need now is to auto tab to the second LINE since the selection / scanning of product ID automatically populate the entire line with the following:
(1) Quantity sold
(2) Price
(3) Tax
(4) Account code
(5) Date
(6) User ID

I cannot use auto tab property because it require an input mask , the problem here is that the bar codes lengths are not the same with other products that is why an auto tab cannot work. I have tried the code below it is also failing:

Private Sub Userloged_Change()
If (Me.Userloged <> "") Then
Move to second
Me.ProductID.SetFocus
Exit Sub
End If
End Sub

Regards

Chris
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
If i remember correctly you have a barcode scanner and via input you populate..
When the process finishes your input could generate a New Record like
docmd.GoToRecord,,acNewRec

Open in new window

or if the entries are already there
docmd.GoToRecord,,AcNext

Open in new window

For everything else it would helpful a screenshot and a bit explanation on what you want to achieve
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Most barcode readers can be programmed to append a CrLf (new line) to the scanned code. That should solve your problem.
ste5anSenior Developer

Commented:
[..] since the selection / scanning of product ID automatically populate the entire line with the following [..]
Can you explain this point?

My normal approach is to use an STX/ETX as barcode marker for HID (keyboard input type) scanners. Then use the form key preview event to scan for STX/ETX and populate a buffer:

Option Compare Database
Option Explicit

' Use non-printable characters like STX, ETX.
' Configure your scanner to append them.
Private Const BARCODE_START As Integer = 35 ' For testing purpose on keyboard: #
Private Const BARCODE_END As Integer = 33   ' For testing purpose on keyboard: !

Private m_Buffer As String
Private m_InScan As Boolean

Private Sub Form_KeyPress(KeyAscii As Integer)
  
  Select Case KeyAscii
  Case Is = BARCODE_START
    m_InScan = True
    KeyAscii = 0
  Case Is = BARCODE_END
    m_InScan = False
    KeyAscii = 0
    Me.Caption = "Barcode: '" & m_Buffer & "'"
  Case Else
    If m_InScan Then
      m_Buffer = m_Buffer & Chr(KeyAscii)
      KeyAscii = 0
    End If
  End Select
  
End Sub

Private Sub Form_Load()

  m_Buffer = ""
  m_InScan = False
  me.KeyPreview = True

End Sub

Open in new window

You should also start a timer on receiving the start character and terminate the barcode scanning after some time, a second or so. Cause sometimes the scanners may return garbage.

The line where I set the caption is where you log the scanned barcode in a separate log table and populate your controls and then you can set the focus to the appropriate control.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Okay let as assume no scanner is involved here , now upon selecting the product ID manually all the required controls are populated see photo attached, all I need is to go into the new line automatically  NOT by tabbing through the controls again.

Pos-scanning-invoice.png

Please check  the attached photo.

Regards

Chris
ste5anSenior Developer

Commented:
See John's answer.
John TsioumprisSoftware & Systems Engineer

Commented:
As i said in my 1st post you just have to go to the New Record.
Okay fair enough where do I put the code? which event?

docmd.GoToRecord,,acNewRec

Regards

Chris
Software & Systems Engineer
Commented:
If i am not mistaken your workflow is like this
You scan a value...a method executes...it populates your row...so after the population is done you could move to the new record.
Thank you so much John you saved my day, this was a puzzle! Now i can go and watch TV

Regards

Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial