By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

Grabbing a date from another form

Cintury
P: 81
Hello

I need to take a date from one form and use it in a conditional statement on the other. Question: Is there a way to link data in code from 2 different forms?

Example: (on agency form) If ReceivingAgencyDate < FoodDonationDate Then
MsgBox "You cannot deliver an item before it is donated. Please enter a valid date." End If
Aug 3 '07 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,669
Hello

I need to take a date from one form and use it in a conditional statement on the other. Question: Is there a way to link data in code from 2 different forms?

Example: (on agency form) If ReceivingAgencyDate < FoodDonationDate Then
MsgBox "You cannot deliver an item before it is donated. Please enter a valid date." End If
Expand|Select|Wrap|Line Numbers
  1. 'from anywhere on the agency Form (substitute your Form Name for frmReceiving)
  2. If Forms!frmReceiving![ReceivingAgencyDate] < Forms!frmReceiving![FoodDonationDate] Then
  3.   MsgBox "You cannot deliver an item before it is donated. Please enter a valid date."
  4. End If
Aug 3 '07 #2

Cintury
P: 81
Hi again.

That worked method worked fine when I was working form to form, but I'm working a form and the subform of another form. The question now is how do I call the subform from the form to check some data from the form which is entered last against that of data entered on the subform which is entered first? I've tried:
Expand|Select|Wrap|Line Numbers
  1. Me.[SourceFormObjectNameOfSubForm].Form.ObjectCalledName
  2.  
  3. Me.Form.SubForm.ObjectCalledName
  4.  
  5. Me.ObjectCalledName.Form.[SourceFormObjectNameOfSubForm]
  6.  
None of these has worked in the slightest I always receive a runtime error.
Any help would be greatly appreciated.
Thanks
Aug 8 '07 #3

ADezii
Expert 5K+
P: 8,669
Hi again.

That worked method worked fine when I was working form to form, but I'm working a form and the subform of another form. The question now is how do I call the subform from the form to check some data from the form which is entered last against that of data entered on the subform which is entered first? I've tried:
Expand|Select|Wrap|Line Numbers
  1. Me.[SourceFormObjectNameOfSubForm].Form.ObjectCalledName
  2.  
  3. Me.Form.SubForm.ObjectCalledName
  4.  
  5. Me.ObjectCalledName.Form.[SourceFormObjectNameOfSubForm]
  6.  
None of these has worked in the slightest I always receive a runtime error.
Any help would be greatly appreciated.
Thanks
To reference a Sub-Form on another Form:
Expand|Select|Wrap|Line Numbers
  1. Forms!frmYourForm![Sub-Form_Control_Name]
To reference a Control on a Sub-Form on another Form:
Expand|Select|Wrap|Line Numbers
  1. Forms!frmYourForm![Sub-Form_Control_Name].Form![Control_Name]
Aug 8 '07 #4

Cintury
P: 81
Thank you for the reply. At least I'm getting an error that looks like I'm closer to solving the problem. I'd like some feedback on whether or not this error is possible to circumvent.

[ERROR]
Run-time error '2467':
The expression you entered refers to an object that is closed or does not exist.
[/ERROR]

I have verified that I am using the correct name of the subform from the main form's properties and that the control i am trying to connect to is spelled correctly so I am assuming that the object is closed. I am wondering what to do about that?

Thank you in advance for any assistance.
Aug 8 '07 #5

Post your reply

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