Derek Brown
asked on
SubForm Link criteria when using form visible true or false
Can I use a version of the following when simply making a subform visible or invisible rather than opening and closing. I'm trying to keep invisible subform synchronized with main and have the link field in subform populated when I add a new record to the main form
Dim stLinkCriteria As String
stLinkCriteria = "[ItemNumber]=" & Me![ItemNumber]
DoCmd.OpenForm "MoreDetails", , , stLinkCriteria
Dim stLinkCriteria As String
stLinkCriteria = "[ItemNumber]=" & Me![ItemNumber]
DoCmd.OpenForm "MoreDetails", , , stLinkCriteria
Is this 'subform' a popup or a true subform embedded in the main form? If it is an embedded subform, then you can synchronize the sub and main form by including the Item Number in the master/child links.
ASKER
Thank you
I have a linked field in the sub/mainform
It's a true subform. As with all subforms I find that the most frustrating thing is that when moving to a new record the subform link field is not made until the main form has been saved or edited first. So you can get this ridiculous situation where the user moves to a new record and immediately tries to enter information in the visible subform Causing a "cannot update" error. So I make the subform invisible until data is added and saved to the main form.
So now when I click the make subform visible button on a main form that has not been saved I would be forced to give message "enter information on the main form first". To overcome this When the user clicks the make subform visible button I have to save the main form and then code
If IsNull(subform linked field)=true then
subform linked field= Mainform Linked field.
end if
That's why I asked is there something like the code for on open. I can see how the form filter code will work but does it overcome the problem of a new record as above?
I have a linked field in the sub/mainform
It's a true subform. As with all subforms I find that the most frustrating thing is that when moving to a new record the subform link field is not made until the main form has been saved or edited first. So you can get this ridiculous situation where the user moves to a new record and immediately tries to enter information in the visible subform Causing a "cannot update" error. So I make the subform invisible until data is added and saved to the main form.
So now when I click the make subform visible button on a main form that has not been saved I would be forced to give message "enter information on the main form first". To overcome this When the user clicks the make subform visible button I have to save the main form and then code
If IsNull(subform linked field)=true then
subform linked field= Mainform Linked field.
end if
That's why I asked is there something like the code for on open. I can see how the form filter code will work but does it overcome the problem of a new record as above?
ASKER
Thank you
I have a linked field in the sub/mainform
It's a true subform. As with all subforms I find that the most frustrating thing is that when moving to a new record the subform link field is not made until the main form has been saved or edited first. So you can get this ridiculous situation where the user moves to a new record and immediately tries to enter information in the visible subform Causing a "cannot update" error. So I make the subform invisible until data is added and saved to the main form.
So now when I click the make subform visible button on a main form that has not been saved I would be forced to give message "enter information on the main form first". To overcome this When the user clicks the make subform visible button I have to save the main form and then code
If IsNull(subform linked field)=true then
subform linked field= Mainform Linked field.
end if
That's why I asked is there something like the code for on open. I can see how the form filter code will work but does it overcome the problem of a new record as above?
I have a linked field in the sub/mainform
It's a true subform. As with all subforms I find that the most frustrating thing is that when moving to a new record the subform link field is not made until the main form has been saved or edited first. So you can get this ridiculous situation where the user moves to a new record and immediately tries to enter information in the visible subform Causing a "cannot update" error. So I make the subform invisible until data is added and saved to the main form.
So now when I click the make subform visible button on a main form that has not been saved I would be forced to give message "enter information on the main form first". To overcome this When the user clicks the make subform visible button I have to save the main form and then code
If IsNull(subform linked field)=true then
subform linked field= Mainform Linked field.
end if
That's why I asked is there something like the code for on open. I can see how the form filter code will work but does it overcome the problem of a new record as above?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks!!
Derek
Derek
Open in new window