I have several text boxes that get updated with information pulled from a query and stuck into an array. It's long, code that I want to shorten. I tried putting each text field into an array, an array but got type mismatch and other errors. There are 2 blocks of code I want to shorten, the first is
FromRecordset.MoveFirst
If Not FromRecordset.EOF Then
Do
With FromRecordset
If IsNull(!Profession) Then
FData(1) = " "
Else
FData(1) = ![Profession]
End If
If IsNull(![Direct Dial]) Then
FData(2) = " "
Else
FData(2) = ![Direct Dial]
End If
If IsNull(![Mobile]) Then
FData(3) = " "
Else
FData(3) = ![Mobile]
End If
(repeated 11 times)
The second block of code is:
Prf.SetFocus
Forms!People.Prf.Text = FData(1)
DD.SetFocus
Forms!People.DD.Text = FData(2)
Mobile.SetFocus
Forms!People.Mobile.Text = FData(3)
(Also repeated 11 times)
I have a need to do this in many more places, so if I can get a solution here, it'll reduce my frustration levels and help me beat a deadline. Many thanks
FromRecordset.MoveFirst
If Not FromRecordset.EOF Then
Do
With FromRecordset
If IsNull(!Profession) Then
FData(1) = " "
Else
FData(1) = ![Profession]
End If
If IsNull(![Direct Dial]) Then
FData(2) = " "
Else
FData(2) = ![Direct Dial]
End If
If IsNull(![Mobile]) Then
FData(3) = " "
Else
FData(3) = ![Mobile]
End If
(repeated 11 times)
The second block of code is:
Prf.SetFocus
Forms!People.Prf.Text = FData(1)
DD.SetFocus
Forms!People.DD.Text = FData(2)
Mobile.SetFocus
Forms!People.Mobile.Text = FData(3)
(Also repeated 11 times)
I have a need to do this in many more places, so if I can get a solution here, it'll reduce my frustration levels and help me beat a deadline. Many thanks