jfgambit
Kinetic Card Dealer
- Local time
- Today, 01:58
- Joined
- Jul 18, 2002
- Messages
- 798
Hello All:
I have the following code behind a command button on a form. In essense, it looks at each designated text field to see if it is already populated with a code, if it is not then it populates the field with the active code on the form. If the 1st text box is occupied it moves to the next until it runs out of text boxes and then a message is given to the user that there are no available text boxes on the form. Is there a better way to do this with a Loop statement and if so, can i get an example from someone???
Thanks.
Private Sub Command115_Click()
'Checks the Buyer Text fields in the Buyer Query Form to see if there are open available
'text fields to apply the select Buyer Numbers too. If all fields are occupied it returns
'a failure message.
Forms!frmBuyerQuery!BuyerText.SetFocus
If Forms!frmBuyerQuery!BuyerText.Text = "" Then
Forms!frmBuyerQuery!BuyerText.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText2.SetFocus
If Forms!frmBuyerQuery!BuyerText2.Text = "" Then
Forms!frmBuyerQuery!BuyerText2.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText3.SetFocus
If Forms!frmBuyerQuery!BuyerText3.Text = "" Then
Forms!frmBuyerQuery!BuyerText3.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText4.SetFocus
If Forms!frmBuyerQuery!BuyerText4.Text = "" Then
Forms!frmBuyerQuery!BuyerText4.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText5.SetFocus
If Forms!frmBuyerQuery!BuyerText5.Text = "" Then
Forms!frmBuyerQuery!BuyerText5.Text = Me!BuyerID
Else
MsgBox "You have reached the maximum limit of Buyer Numbers.", vbOKOnly, "BUYER NUMBERS"
End If
End If
End If
End If
End If
DoCmd.Close
End Sub
I have the following code behind a command button on a form. In essense, it looks at each designated text field to see if it is already populated with a code, if it is not then it populates the field with the active code on the form. If the 1st text box is occupied it moves to the next until it runs out of text boxes and then a message is given to the user that there are no available text boxes on the form. Is there a better way to do this with a Loop statement and if so, can i get an example from someone???
Thanks.
Private Sub Command115_Click()
'Checks the Buyer Text fields in the Buyer Query Form to see if there are open available
'text fields to apply the select Buyer Numbers too. If all fields are occupied it returns
'a failure message.
Forms!frmBuyerQuery!BuyerText.SetFocus
If Forms!frmBuyerQuery!BuyerText.Text = "" Then
Forms!frmBuyerQuery!BuyerText.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText2.SetFocus
If Forms!frmBuyerQuery!BuyerText2.Text = "" Then
Forms!frmBuyerQuery!BuyerText2.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText3.SetFocus
If Forms!frmBuyerQuery!BuyerText3.Text = "" Then
Forms!frmBuyerQuery!BuyerText3.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText4.SetFocus
If Forms!frmBuyerQuery!BuyerText4.Text = "" Then
Forms!frmBuyerQuery!BuyerText4.Text = Me!BuyerID
Else
Forms!frmBuyerQuery!BuyerText5.SetFocus
If Forms!frmBuyerQuery!BuyerText5.Text = "" Then
Forms!frmBuyerQuery!BuyerText5.Text = Me!BuyerID
Else
MsgBox "You have reached the maximum limit of Buyer Numbers.", vbOKOnly, "BUYER NUMBERS"
End If
End If
End If
End If
End If
DoCmd.Close
End Sub