I am working with Access 2013 in Windows 8
Due to changes I made to make another form work, I have created myself a new problem with a different form.
I have 2 tables
Table 1 = parent
Table 2 = child
The parent table must have at least 1 child.
On my form, I am trying to figure out how to prevent the main form from closing or going to a new record unless the sub has also created a record.
I have tried numerous methods that have failed.
I have been focused on an event for my close button. Once this is working I will include it with my new record button. I have the form set so these buttons are the only option to close or get a new record.
None of my research has given me enough information to make this work. Every time I try to get an event to look at the sub form I receive the following error....
Error Message: The object doesn't contain the Automation object 'Forms.' You tried to run a Visual Basic procedure to set a proper or method for an object. However, the component doesn't make the property or method available for Automation operations.
'Forms' is replaced with what ever control of the sub form I have tried. This error was from attempting to use an If statement in a macro:
I have tried to use - IsNull also
Not sure if I should be using an If statement and I know DCount is for tables and queries, but I didn't know what else to try.
I am using
IF "whatever I can think of to try"
then message box
then go to control (the one I want filled in on the sub form, though I don't care where it goes)
Else close form
I am using macros.
I would love some insight...
Thanks for all of the help so far.
Due to changes I made to make another form work, I have created myself a new problem with a different form.
I have 2 tables
Table 1 = parent
Table 2 = child
The parent table must have at least 1 child.
On my form, I am trying to figure out how to prevent the main form from closing or going to a new record unless the sub has also created a record.
I have tried numerous methods that have failed.
I have been focused on an event for my close button. Once this is working I will include it with my new record button. I have the form set so these buttons are the only option to close or get a new record.
None of my research has given me enough information to make this work. Every time I try to get an event to look at the sub form I receive the following error....
Error Message: The object doesn't contain the Automation object 'Forms.' You tried to run a Visual Basic procedure to set a proper or method for an object. However, the component doesn't make the property or method available for Automation operations.
'Forms' is replaced with what ever control of the sub form I have tried. This error was from attempting to use an If statement in a macro:
Code:
DCount((([Forms]![MainFormName]![SubFormName].[Forms]![NameofField])<1),1,0)
Not sure if I should be using an If statement and I know DCount is for tables and queries, but I didn't know what else to try.
I am using
IF "whatever I can think of to try"
then message box
then go to control (the one I want filled in on the sub form, though I don't care where it goes)
Else close form
I am using macros.
I would love some insight...
Thanks for all of the help so far.
Comment