My Assistant
![]() ![]() |
|
|
Mar 11 2004, 03:30 AM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 51 |
In my form there is a field known as CurrencyCombo. I want the user to select currency from this CurrencyCombo before proceed to the rest of the fields. If the user didn't select the CurrencyCombo, then i want it to set focus back to CurrencyCombo until the user select.
Below is the code: Private Sub CurrencyCombo_Enter() If Me.CurrencyCombo = Null Then GoTo CurrencyComboErr If Me.CurrencyCombo <> "" Then GoTo ExitSub CurrencyComboErr: MsgBox "Please select currency" Me.CurrencyCombo.SetFocus If Me.CurrencyCombo = Null Then GoTo CurrencyComboErr ExitSub ExitSub: End Sub After i run this code, the user still able to go to other field eventhough the user didn't select currency. How can i make so that the user have to select the currency and "disable" to get out of this field if the user didn't select the currency? |
|
|
|
Mar 11 2004, 03:36 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 4,162 From: Washington, USA |
Place this code in the AfterUpdate event of the combobox;
If Me.CurrencyCombo = Null Then MsgBox "Please select currency" Me.CurrencyCombo.SetFocus Docmd.GoToControl "CurrencyCombo" Else Exit Sub End If Daniel |
|
|
|
Mar 11 2004, 04:10 AM
Post
#3
|
|
|
UtterAccess Enthusiast Posts: 51 |
Dear Daniel:
I tried the below code: Private Sub CurrencyCombo_AfterUpdate() If Me.CurrencyCombo = "" Then GoTo CurrencyComboErr If Me.CurrencyCombo <> "" Then GoTo CurrencyComboExit CurrencyComboErr: MsgBox "Please select currency" Me.CurrencyCombo.SetFocus DoCmd.GoToControl "CurrencyCombo" GoTo ExitSub CurrencyComboExit: Me.InvoiceExchangeRate = Forms!Invoice!CountryCodeSubform!ExRateFXtoMYR DoCmd.RunCommand acCmdSaveRecord GoTo ExitSub ExitSub: End Sub BUT it still doesn't work. The user still can leave the currency field blank without selecting it from the combo box. What wrong with my code? |
|
|
|
Mar 11 2004, 04:28 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 4,162 From: Washington, USA |
Hmmm weird,
Maybe workaround, there must be an easier way to do this, set the validation rule in the field properties of the field which is related to the combobox... Daniel |
|
|
|
Mar 11 2004, 04:34 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 4,162 From: Washington, USA |
Or if its always required, then set the field propperties on Required.
Daniel |
|
|
|
Mar 11 2004, 04:42 AM
Post
#6
|
|
|
UtterAccess Enthusiast Posts: 51 |
ok
thanks |
|
|
|
Mar 11 2004, 05:03 AM
Post
#7
|
|
|
UA Editor + Utterly Certified Posts: 22,726 From: Melton Mowbray,Leicestershire (U.K) |
Hi
Would it a better option to place your code in the "BeforeUpdate" event of the form, placing your code in the "afterupdate" event of the combo will not trigger "unless" you select something?. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 11:13 AM |