Well, I should start off by saying that this is really a site for developers to help each other. Simply asking for the work to be done for you is generally frowned upon.
However, this once I'll show you how to manage it. You will be expected to be able to cope with the basics in future though. Possibly visit
Microsoft Access Tutorials (Strive4Peace) and learn the basics first if you need more help.
Here's another point. In order to be able to help I need to know what you're working with as far as control names go and various other basic information required for your question to make proper sense. For now I'll assign my own names and hope you can recognise what's what. If you ever write another question make sure you do a better job of explaining the situation fully. As you haven't included any such information I will also have to assume that you're working in India and the PIN you refer to is the six-digit PIN they use there.
Anyway, for your situation you first need to ensure that the two unbound controls properly reflect the correct data each time a record is made the current one. This requires them to be set in the Form's Current event procedure ([txtHomeAddress] may be invisible but must exist. If visible then it should be locked.) :
- Private Sub Form_Current()
-
With Me
-
.txtCity = Null
-
.txtPIN = Null
-
If .txtHomeAddress Like "* ######" Then
-
.txtCity = Trim(Left(.txtHomeAddress, Len(.txtHomeAddress) - 6)
-
.txtPIN = Right(.txtHomeAddress, 6)
-
ElseIf .txtHomeAddress Like "######" Then
-
.txtPIN = .txtHomeAddress
-
ElseIf .txtHomeAddress > "" Then
-
.txtCity = Trim(.txtHomeAddress)
-
End If
-
End With
-
End Sub
Next you need to make sure that if either is updated then the updated value is applied back into
Me.txtHomeAddress
appropriately.
- Private Sub txtCity_AfterUpdate()
-
With Me
-
.txtHomeAddress = Trim((.txtCity + " ") & .txtPIN)
-
End With
-
End Sub
-
-
Private Sub txtPIN_AfterUpdate()
-
With Me
-
.txtHomeAddress = Trim((.txtCity + " ") & .txtPIN)
-
End With
-
End Sub