Move Typed value from field to another field

Alhakeem1977

Registered User.
Local time
Today, 20:41
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:
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
 
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
 
is AcrualAC field supposed to be the [ActualAC] control?
 
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!
 
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

Back
Top Bottom