Using Access VBA code to copy between unbound- and bound fields (1 Viewer)

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
I have 2 fields in an MS Access form "BTKForm" sending and picking up data form a bank terminal.
Code is executed by clicking a Button on the form.

Field 1, "IssuerID", is an Unbound field picking up a code from the bank terminal. It's numbers between 0 and 100, representing the Card provider.

Field 2 - "IsID", is a value field linked to a table.

I want to take care of (save) (copy) "IssuerID" in to "IsID".

I have been struggling with the problem for a long time.
Nobody have so far been able to help me.
Please, can somebody help? :banghead:

Code is:
Code:
[SIZE=2]
 Public Sub TransferAmount_Click()
Set BAX = CreateObject("BankAxeptSrv.BankAxeptAutomation")
If BAX.Connected And BAX.LicenseVerified And Not BAX.BankMode Then
Dim amnt As Long
Dim cashb As Long
amnt = Round(Amount.Value * 100)
cashb = Round(Cashback.Value * 100)
If BAX.TransferAmount(amnt, cashb) Then
While BAX.BankMode
While BAX.GetNoOfDisplayMsgs > 0
DisplayMsgs.SetFocus
DisplayMsgs.AddItem (BAX.GetDisplayMsg)
DoEvents
Wend
DoEvents
Wend
While BAX.GetNoOfPrinterMsgs > 0
PrinterMsgs.SetFocus
PrinterMsgs.AddItem (BAX.GetPrinterMsg)
DoEvents
Wend
If BAX.TransactionOK Then
TransactionStatus.SetFocus
TransactionStatus.AddItem ("OK")
IssuerID.SetFocus
IssuerID.AddItem (Str(BAX.GetIssuerID)) ' Getting IssuerID from bank terminal.
Dim lPauseTime As Long
Dim lStart As Long
lPauseTime = 3 'Seconds
lStart = Timer
Do While Timer < lStart + lPauseTime
DoEvents
Loop
Me.IsID = Me.IssuerID 
DoCmd.RunMacro "Auto A kort" 'Closes the Form and printing a Check. 
Else
TransactionStatus.SetFocus
TransactionStatus.AddItem ("AVVIST")
IssuerID.SetFocus
IssuerID.AddItem ("99")
DoCmd.RunMacro "Avvist 2.BTKForm" 'what is done if tranaction is dismissed.
End If
End If
End If
End Sub

 [/SIZE]

 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:13
Joined
Aug 30, 2003
Messages
36,126
Something like

Me.IsID = Me.IssueID
 

Solo712

Registered User.
Local time
Today, 16:13
Joined
Oct 19, 2012
Messages
828
I have 2 fields in an MS Access form "BTKForm" sending and picking up data form a bank terminal.
Code is executed by clicking a Button on the form.

Field 1, "IssuerID", is an Unbound field picking up a code from the bank terminal. It's numbers between 0 and 100, representing the Card provider.

Field 2 - "IsID", is a value field linked to a table.

I want to take care of (save) (copy) "IssuerID" in to "IsID".

I have been struggling with the problem for a long time.
Nobody have so far been able to help me.
Please, can somebody help? :banghead:

Code is:
Code:
[SIZE=2]Public Sub TransferAmount_Click()[/SIZE]
[SIZE=2]Set BAX = CreateObject("BankAxeptSrv.BankAxeptAutomation")[/SIZE]
[SIZE=2]If BAX.Connected And BAX.LicenseVerified And Not BAX.BankMode Then[/SIZE]
[SIZE=2]Dim amnt As Long[/SIZE]
[SIZE=2]Dim cashb As Long[/SIZE]
[SIZE=2]amnt = Round(Amount.Value * 100)[/SIZE]
[SIZE=2]cashb = Round(Cashback.Value * 100)[/SIZE]
[SIZE=2]If BAX.TransferAmount(amnt, cashb) Then[/SIZE]
[SIZE=2]While BAX.BankMode[/SIZE]
[SIZE=2]While BAX.GetNoOfDisplayMsgs > 0[/SIZE]
[SIZE=2]DisplayMsgs.SetFocus[/SIZE]
[SIZE=2]DisplayMsgs.AddItem (BAX.GetDisplayMsg)[/SIZE]
[SIZE=2]DoEvents[/SIZE]
[SIZE=2]Wend[/SIZE]
[SIZE=2]DoEvents[/SIZE]
[SIZE=2]Wend[/SIZE]
[SIZE=2]While BAX.GetNoOfPrinterMsgs > 0[/SIZE]
[SIZE=2]PrinterMsgs.SetFocus[/SIZE]
[SIZE=2]PrinterMsgs.AddItem (BAX.GetPrinterMsg)[/SIZE]
[SIZE=2]DoEvents[/SIZE]
[SIZE=2]Wend[/SIZE]
[SIZE=2]If BAX.TransactionOK Then[/SIZE]
[SIZE=2]TransactionStatus.SetFocus[/SIZE]
[SIZE=2]TransactionStatus.AddItem ("OK")[/SIZE]
[SIZE=2]IssuerID.SetFocus[/SIZE]
[SIZE=2]IssuerID.AddItem (Str(BAX.GetIssuerID)) ' Getting IssuerID from bank terminal.[/SIZE]
[SIZE=2]Dim lPauseTime As Long[/SIZE]
[SIZE=2]Dim lStart As Long[/SIZE]
[SIZE=2]lPauseTime = 3 'Seconds[/SIZE]
[SIZE=2]lStart = Timer[/SIZE]
[SIZE=2]Do While Timer < lStart + lPauseTime[/SIZE]
[SIZE=2]DoEvents[/SIZE]
[SIZE=2]Loop[/SIZE]
[SIZE=2]Me.IsID = Me.IssuerID [/SIZE]
[SIZE=2]DoCmd.RunMacro "Auto A kort" 'Closes the Form and printing a Check. [/SIZE]
[SIZE=2]Else[/SIZE]
[SIZE=2]TransactionStatus.SetFocus[/SIZE]
[SIZE=2]TransactionStatus.AddItem ("AVVIST")[/SIZE]
[SIZE=2]IssuerID.SetFocus[/SIZE]
[SIZE=2]IssuerID.AddItem ("99")[/SIZE]
[SIZE=2]DoCmd.RunMacro "Avvist 2.BTKForm" 'what is done if tranaction is dismissed.[/SIZE]
[SIZE=2]End If[/SIZE]
[SIZE=2]End If[/SIZE]
[SIZE=2]End If[/SIZE]
[SIZE=2]End Sub[/SIZE]

How about: Me!IsID= Me!IssuerID, did that work ?

Best,
Jiri
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:13
Joined
Aug 30, 2003
Messages
36,126
I must have had my cloak of invisibility on... :p
 

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
Thank you for the answers.

Me.IsId
=Me.IssuerID, as you suggests, is already in the VBA code.

It’s a timer in the code, set to 3 seconds who take care of the time it takes to get the IssuerID from the bank terminal.

Me.IsID
=Me.IssuerID is simply not working.

Is it another way doing this?
 

RainLover

VIP From a land downunder
Local time
Tomorrow, 06:13
Joined
Jan 5, 2009
Messages
5,041
Test both IsID and IssuerID to see if they have a value.

A message box will suffice.
 

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
Hi.

The biggest problem for testing this VBA code, is that I am dependent on getting a lott of data from the bank terminal to run code properly.

I can see I am getting the value inn IssuerID Field thanks to the timer.

The field becoming blue and the number 1 is added.
After that the: Me.IsID
= Me.IssuerID is done before DoCmd.RunMacro "Auto A kort"

Hope you guys understand my English, I am normally speaking Norwegian.
 

Solo712

Registered User.
Local time
Today, 16:13
Joined
Oct 19, 2012
Messages
828
Thank you for the answers.

Me.IsId=Me.IssuerID, as you suggests, is already in the VBA code.

It’s a timer in the code, set to 3 seconds who take care of the time it takes to get the IssuerID from the bank terminal.

Me.IsID=Me.IssuerID is simply not working.

Is it another way doing this?

Yes, your answer is in post #3. Use exclamation marks instead of dots when referring to controls' values.
 

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
Thank you.

I will do that tomorrow morning.
 

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
I have tried to day and Me!IsID= Me!IssuerID is not working.

What I have done now is connected the Unbond field "IssuerID" to
the underlying Query as Value list.
When I am running the VBA code manually, I can see the "IssuerID"
value being loaded from the bank terminal in to the field.
I can save the "IssuerId" to the Query by clicking on the field
with left mouse button.

Is it a way to do that by using code?
 

RainLover

VIP From a land downunder
Local time
Tomorrow, 06:13
Joined
Jan 5, 2009
Messages
5,041
You have not answered my question from post number.

Are you going to do that or not.
 

stigb

New member
Local time
Today, 13:13
Joined
Apr 21, 2015
Messages
5
You have not answered my question from post number.

Are you going to do that or not.
I am sorry RainLover, thank you for trying to help me.

I don't know how to Test both IsID and IssuerID to see if they have a value using a Message Box.

So far I have been testing the code directly on a Register in a Brew Pub before opening hours, buying a Coke by credit card.

What I have discovered though, is that pointing on "IssuerID" with the cursor clicking the left mouse button save the value picked up from bank terminal.

That is simply what I am trying to do.

Sorry for my English.
 

RainLover

VIP From a land downunder
Local time
Tomorrow, 06:13
Joined
Jan 5, 2009
Messages
5,041
Put a Message block in the middle of the code straight after it is supposed to obtain a value.

Look at Access for help.
 

Users who are viewing this thread

Top Bottom