Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing Data in a Subform

Status
Not open for further replies.

eAlchemist

Technical User
Aug 28, 2003
64
US

I've specified data from a record selected in a subform as a parameter in one of my queries. When I launch the form from my switchboard, the query can't find the data item, but when I launch the form from the database window, the query works fine. Any one have any idea what is going on here?

Thanks,
Chris
 
When launched from the database window:
[Forms]![subform name]![parameter control]
When launched from the switchboard:
[Forms]![switchboard name]![subform control name].Form![parameter control]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Your 'Data Entry' property in the form is probably set to 'No' while your Switchboard is probably opening it for 'Data Entry'. Change the Switchboard entry for that form to 'Open Form in Edit Mode'.


traingamer
 
This is a subform within a form which is being launched from the switchboard. I've specified the main form in the reference. Would I really need to specify the switchboard? And if so, then what is the syntax including the parent form.

Thanks,
Chris
 
If the switchboard use the OpenForm method:
[Forms]![mainform name]![subform control name].Form![parameter control]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The form doesn't have an OpenForm method. I'm not exactly sure how, but the form is already loaded- I guess because I have code on an event in the form. All I had to do was to say formname.visible.

switchboard - frmSwitchboard
main form - frmContact
sub form - sfrmGift

**Note - the sbu form doesn't show up in the object browser- i guess because it doesn't have any code on it.

Thanks,
Chris
 
So, have you tried this ?
Forms]![frmContact]![sfrmGift].Form![parameter control]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yeah, that's exactly what I have, but it doesn't work when I lauch the form from the switchboard. Is there something about needing to load the subform? I got the text you provided by going through the wizard to locate the control.

Thanks,
Chris
 
Often it is hard to say why things don't work in MS Access.
Following sound and WMD (weapons of mass destruction) proof design practices on the other hand will ensure that you maximize chances to make things work right.
If I were you I would do the following:
- make sure that everything works the way you want when you open your parent form from DB window: you scroll all records on parent/child forms and can run the query
- then add a command button to switch board with openForm command in onClick event and make sure that things are the same as when you work from DB window.
You can work your way from another end as well - if query doesn't find parameter - there is no parameter! Why? Control is not populated, control value is Null, empty string or the value that yields no data from the query........
 
specified data from a record selected in a subform as a parameter in one of my queries

First, using the full reference as provided by PHV should work regardless of referencing it from a form, switchboard or the database window. I have to wonder if the problem is that there may be no record selected in the subform??
- Is the subform contineous?
- Is the form open?

I am sure you have caught the minor typo, the missing opening square bracket...
[COLOR=blue yellow][[/color]Forms]![frmContact]![sfrmGift].Form![parameter control]
...from the post.

Richard
 
Definetly no typo. The subform is continuous and the form is open. I did forget to mention that this is a Db that someone else designed originally. I'm fixing it up. It looks like the form was done is a wizard, because while the textboxes and lables are stacked vertically in design view, they appear horizontally in form view. I can't seem to change that- I'm assuming that is something a wizard did. Am I mistaken? Would that affect anything?

Thanks,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top