469,645 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Check field in subform

I have a form with subforms on it (subforms are designed on tabcontrol and each has separate page)

After user enter information on form and tries to hit "Save" button i would like the access first to check if value in a subform field is not empty.

It is tblTakeOrder form. When user fills information on form with order id, client name and required date and try to save it - access needs to check SubForm "Order details" if orders price is typed in it

Trying to use this code but doesn't work:
Expand|Select|Wrap|Line Numbers
  1. Forms![TakeOrder]![Orderdetails subform].Form![Price].SetFocus
  2. If Me!Orderdetails subform.Price Is Null Then
  3.  
  4. MsgBox "Please insert price of the order"
  5. Else
  6.  
  7.     DoCmd.RunCommand acCmdSaveRecord
  8.  
  9.     End If
  10. End Sub
  11.  
Jun 2 '10 #1

✓ answered by ChipR

To refer to a control on a subform with code on the main form, try this syntax:
Expand|Select|Wrap|Line Numbers
  1. Me!Subform1.Form!ControlName
Make sure that you replace Subform1 with the name of the subform control on the main form.

3 7462
ChipR
1,287 Expert 1GB
To refer to a control on a subform with code on the main form, try this syntax:
Expand|Select|Wrap|Line Numbers
  1. Me!Subform1.Form!ControlName
Make sure that you replace Subform1 with the name of the subform control on the main form.
Jun 2 '10 #2
That worked, thank you.
Jun 2 '10 #3
Thanks so much!

This was very helpful :)
Jul 20 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Simon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.