Solved Transferring data from unbound MS Access Form to another form (2 Viewers)

nector

Member
Local time
Tomorrow, 01:43
Joined
Jan 21, 2020
Messages
559
This scenario is based on a POS touch screen where you cannot see any keyboard for data entry, now in MS Access we built a Keyboard unbound form to assist in capturing data. The reason why we did it that way is that there are some situations when the scanner fails to scan the barcode, and so the option or method used is to enter the barcode manually. That is okay if there is a keyboard but without a keyboard it’s almost impossible to do it.

I have assisted the users to transfer the captured data into the required scanning control using this method below, but it does not go into the subform datasheet rows, that is where my problem is, any idea here will be highly appreciated.

Code:
Private Sub BtnEnterKey_Click()
Forms!frmCustomerInvoice!txtProductCode.Value = Me.Calc
End Sub
To appreciate the question above kindly get the database attached and simply go to properties and check the unblock field then it will open. For the keyboard to work simply compile the code.


1759398979665.png
 

Attachments

try this, make sure you read the VBA code.
you also remove "unnecessary" keys on your Keyboard POS, since it is mainly used
for manual entry of Product Code (no math involved).
 

Attachments

Last edited:
try this, make sure you read the VBA code.
you also remove "unnecessary" keys on your Keyboard POS, since it is mainly used
for manual entry of Product Code (no math involved).
Many thanks arnelgp exactly that is what I was looking for
 
try this, make sure you read the VBA code.
you also remove "unnecessary" keys on your Keyboard POS, since it is mainly used
for manual entry of Product Code (no math involved).

The demo db works ok but the same concept when I transfer it to the actual POS I'm getting an on the calculator code even after changing the external sub to public.

Here are the changes I did make

Code:
Public Sub txtProductCode_AfterUpdate()
Dim lngProdID As Long
    
    If Not (IsNull(mID)) Then
        DoCmd.GoToControl "sfrmPosLineDetails Subform"
              
        With Me![sfrmPosLineDetails Subform].Form
            ![ProductID] = mID
            ![QtySold] = 1
            ![ProductName] = DLookup("ProductName", "tblProducts", "BarCode = '" & Me.txtProductCode & "'")
            ![TaxClassA] = DLookup("vatCatCd", "tblProducts", "BarCode = '" & Me.txtProductCode & "'")
            ![SellingPrice] = DLookup("dftPrc", "tblProducts", "BarCode = '" & Me.txtProductCode & "'")
            ![Tax] = DLookup("VAT", "tblProducts", "BarCode = '" & Me.txtProductCode & "'")
            ![RRP] = 0
            ![ItemesID] = DCount("[QtySold]", "tblPosLineDetails", "[ItemSoldID] =" & Me.txtDcounting)
        End With
    DoCmd.GoToRecord , , acNewRec
        
    End If
        
    Me.txtProductCode = Null
    Me.txtProductCode.SetFocus
End Sub


Public Sub txtProductCode_BeforeUpdate(Cancel As Integer)
If IsNull(Me.DocID) Then
Beep
MsgBox "Please select the document type now", vbCritical, "You have not selected the document type"
Cancel = True
Exit Sub
End If

bolValid = True
    If Not IsNull(Me.txtProductCode) Then
        ' now check if it is valid
        mID = DLookup("ProductID", "tblProducts", "BarCode = '" & Me.txtProductCode & "'")
        
        bolValid = (IsNull(mID) = False)
        Cancel = Not bolValid
        If Cancel Then
            MsgBox "Barcode is not on product table!"
        End If
    
    End If

End Sub


POS Main Form.jpg



POS Main Form2 VBA Code.jpg
 
This is why you should not use bang but dot notation wherever possible and do not EVER EVER put spaces in any name of anything.
Are you sure you have a control of that name?
Me![sfrmPosLineDetails Subform]
but this would have told you if using dot and a normal name.
me.sfrmProslineDetails

Why would you even name it that with subform at the end if you start it with sFrm?
 

Users who are viewing this thread

Back
Top Bottom