 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 15th, 2004, 12:54 PM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
form/subform problem
Hi!
I have an form with a subform used for order entry.
The subform is used to enter the order detail. Once the item is selected (on lost focus) the focus is set on the "order quantity" control to make sure there is a quantity entered. It's working fine... but if the user clicks on one of the form's control, the order can be processed with a quantity set to zero. I don't know how I can force Access to set the focus on the quantity control (in subform) when a quantity has not been entered.
Thanks in advance for your help.
Chantal
|
|

June 17th, 2004, 12:18 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When the subform itself, loses focus, run code...
Private Sub Form_LostFocus (Cancel As Integer)
If IsNull(subfrmName.txtQuantityControl) Or subfrmName.txtQuantityControl = "" Then
subfrmName.txtQuantityControl.SetFocus
End If
MsgBox "Quantity Control must have valid value, no nulls hombré!"
End Sub
j'espere que vous trouverez ma réponse aidant, bonne chance!
Hope this helps, good Luck!
|
|

June 18th, 2004, 10:07 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I did try your suggestion on the form's lost focus event, but it doesn't work... In a debug mode, Access doesn't even look at the code under this event...
Merci pour ton aide
Thanks for your help
:)
|
|

June 18th, 2004, 06:02 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
chacquard, I am sorry, if I understand correctly, it's once you leave focus from the subform, if the subform[orderquantity] = 0, you want focus back on the subform, set to that control.
The event should be "OnExit" on the subform...but, I can't get the "SetFocus" to work, but I can other methods....
Is this an option...
Private Sub SubFormName_Exit (Cancel As Integer)
If IsNull(Forms!MainFormName![subFormName].Form.QuantityControl ) Or Forms!MainFormName![subFormName].Form.QuantityControl = "" Then
Forms!MainFormName![subFormName].Form.QuantityControl.ForeColor = vbRed
MsgBox "Quantity Control must have valid value, no nulls hombré!"
Else
Forms!MainFormName![subFormName].Form.QuantityControl.ForeColor = vbBlack
End If
End Sub
Encore une fois, bonne chance!
|
|

June 21st, 2004, 02:45 PM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You do understand correctly what I am trying to do.
I tried the "on exit" event on the subform. I also and modified your code and it didn't process at all...
I tried other events for the subform: "on unload, on close, on lost focus, on deactivate" nothing seems to be working out for me.
Je ne sais plus quoi faire!!!
I don't know what to do anymore :(
Chantal
|
|

June 21st, 2004, 10:45 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chantal, when you say, "didn't process", does the program step through at all, or the initial criteria (If IsNull(quantity..... is overlooked, then goes to ....[Quality.Control.ForeColor=vbBlack......does anything take place?
Is the first criteria incorrect (IsNull or ""), or the reference?
Try this slight modification, to help see...
Forms!MainFormName![subFormName].Form.QuantityControl.ForeColor = vbRed
MsgBox "Quantity Control must have valid value, no nulls hombré!"
Else
Forms!MainFormName![subFormName].Form.QuantityControl.ForeColor = vbYELLOW
This may sound obvious, but is {Event Procudure] displayed, in the "Event" tab, of the properties dialog box, for the subform?
Chantal, attempt to trouble shoot. Change the criteria to something obvious, like, If Quantity Control = 56(cause you know, there's a record 56) Then...(again something obvious, maybe on the main form) txtName.ForeColor = vbBlue?
Again, I'm not sure what you mean, "not Processing", Is it the references or the criteria.can you put a "Break" in your code to "Step Through"?
Chantal, the code worked for me above, if that offers any insight?
Si ca ne vous derange pas, montez moi ton code ou, si possible, ton programme(application)?
Peut-être il sera plus facile pour moi, a voir pourquoi il ne marche pas?
j'espere je pourrai t'aider!
à bientôt!
|
|
 |