Move Typed value from field to another field (1 Viewer)

Alhakeem1977

Registered User.
Local time
Today, 07:30
Joined
Jun 24, 2017
Messages
308
Hi All,

I have got two fields in a form one called [AccountNo](ComboBox) and the other one called [ActualAC](Text) I want to move the typed data from AccountNo to AcrualAC field if the value typed not in the list of the Combobox.
How can I achieve this? Please find my code below:
Code:
Private Sub AccountNo_NotInList(NewData As String, Response As Integer)
On Error Resume Next
  DoCmd.Beep
If MsgBox("Sorry, file not received !" & vbCrLf & _
   "* Please provide the Actual A/C # in the field you will be provided. *" _
   , vbCritical, "A/C Not Listed") = vbCritical Then
     Response = acDataErrContinue
           Else
     Response = acDataErrContinue
    End If
Me.AccountNo = 4589
Me.ActualAC.Visible = True
Me.ActualAC.SetFocus
End Sub

Thanks in advance!
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:30
Joined
Oct 29, 2018
Messages
18,962
Hi. How about something like this?
Code:
Private Sub AccountNo_NotInList(NewData As String, Response As Integer)

DoCmd.Beep
MsgBox "Sorry, file not received !" & vbCrLf & _
    "* Please provide the Actual A/C # in the field you will be provided. *" _ 
    , vbCritical, "A/C Not Listed"
Response = acDataErrContinue
Me.ActualAC.Visible = True
Me.ActualAC = NewData

End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:30
Joined
May 7, 2009
Messages
16,393
Code:
Private Sub AccountNo_NotInList(NewData As String, Response As Integer)

DoCmd.Beep
MsgBox "Sorry, file not received !" & vbCrLf & _
    "* Please provide the Actual A/C # in the field you will be provided. *" _ 
    , vbCritical, "A/C Not Listed"
Response = acDataErrContinue
Me.AccountNo.Undo
With Me.ActualAC
    .Visible = True
    .Value = NewData
    .SetFocus
End With
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 05:30
Joined
Feb 19, 2013
Messages
14,358
is AcrualAC field supposed to be the [ActualAC] control?
 

Alhakeem1977

Registered User.
Local time
Today, 07:30
Joined
Jun 24, 2017
Messages
308
Hi. How about something like this?
Code:
Private Sub AccountNo_NotInList(NewData As String, Response As Integer)

DoCmd.Beep
MsgBox "Sorry, file not received !" & vbCrLf & _
    "* Please provide the Actual A/C # in the field you will be provided. *" _ 
    , vbCritical, "A/C Not Listed"
Response = acDataErrContinue
Me.ActualAC.Visible = True
Me.ActualAC = NewData

End Sub

It's working perfectly.
Thank you so much!
 

Alhakeem1977

Registered User.
Local time
Today, 07:30
Joined
Jun 24, 2017
Messages
308
Code:
Private Sub AccountNo_NotInList(NewData As String, Response As Integer)

DoCmd.Beep
MsgBox "Sorry, file not received !" & vbCrLf & _
    "* Please provide the Actual A/C # in the field you will be provided. *" _ 
    , vbCritical, "A/C Not Listed"
Response = acDataErrContinue
Me.AccountNo.Undo
With Me.ActualAC
    .Visible = True
    .Value = NewData
    .SetFocus
End With
End Sub

It's working perfectly getting the same result as theDBguy provided.
Thank you so much both of you!
 

Users who are viewing this thread

Top Bottom