Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2004, 12:54 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default 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
Reply With Quote
  #2 (permalink)  
Old June 17th, 2004, 12:18 AM
Authorized User
 
Join Date: Oct 2003
Location: Toronto, Ontario, Canada.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

Reply With Quote
  #3 (permalink)  
Old June 18th, 2004, 10:07 AM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default

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

:)

Reply With Quote
  #4 (permalink)  
Old June 18th, 2004, 06:02 PM
Authorized User
 
Join Date: Oct 2003
Location: Toronto, Ontario, Canada.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!


Reply With Quote
  #5 (permalink)  
Old June 21st, 2004, 02:45 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default

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

Reply With Quote
  #6 (permalink)  
Old June 21st, 2004, 10:45 PM
Authorized User
 
Join Date: Oct 2003
Location: Toronto, Ontario, Canada.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
form/subform problem chacquard Access VBA 1 November 21st, 2006 06:50 PM
Printing a form with a subform in it jcalfg Access 1 July 25th, 2006 03:40 PM
Cant print when the form become subform yikchin Access 6 November 22nd, 2005 10:22 PM
How to link form and subform method Access 1 July 30th, 2005 02:19 AM
form/subform reference tmc Access 1 August 7th, 2004 04:16 AM



All times are GMT -4. The time now is 06:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.