A Strange Form problem

k209310

Registered User.
Local time
Today, 19:24
Joined
Aug 14, 2002
Messages
184
I have a strange problem and was hoping that someone out there had come accross something similar. Im sorry that this is long winded but im trying to give all the info i can as the problem seems strange to me.

Ok i have many forms. for the sake of this example i have one form that has a text box in. The text box is referenced in a query to allow a variable to be inputted.. When OK is clicked the form a second form opens displaying the results of the query. If i open up the first form from the Form Window in the datase then everything works fine. I get the reasults that i need.

However as i have many forms to allow several search types i have a seperate form to allow a user to select the search type. A search is selected using option buttons that are grouped together using an option group. A user selects a check box and selects OK and the correct search window is displayed. Still no problems

My problem occurs here. I enter the data in to the search window as normal and press OK. I am then confronted by the "Enter Parameter Value" window which is displayed by access if it can not find the form referenced in the query. I cannot understand why this is displayed under this circustance when it is displyed as normal when i open the form from the form window.

There is one final twist. If i open the database and run the select seatrch type then i am confronted with the problem however if i open the form from the form window and run everything (the way it works) AND THEN run the search window (THE WAY IT DOESNT WORK) then everything works fine.

I hope this all makes sense it is hard to describe but i cant for the life of me understand why this is happeneing. Its annoying me.

Thanks for reading and thanks for any replies.

Chris
 
Without exception, the "Enter Parameter Value" pops up because you have asked for something Access couldn't find.

This can be caused by two major "gotcha" cases:

1. The spelling of the desired object is incorrect in the place where you think it should be defined.

2. The object isn't visible in the context where you needed it.

Remedies to (1) involve code review to tediously verify spelling.

Remedies to (2) involve the issue of properly qualifying the object you wanted to use.

Note that sometimes, case 2 involves things that can NEVER be visible from the desired context because the object in question will either always be locked or will never be open.

In general, if you are using a form object in your query, the form MUST be open. Otherwise that object doesn't exist. Hence it isn't visible.
 
Thanks for the reply.

All of the spellings are correct as the forms open perfectly under different conditions. Even if i open the Forms from a switchboard everything works fine.

The only time i have a problem is when i have to open up a search variable form from another form. I cant undersand why this is happening.


In the reply you mention "properly qualifying the object you wanted to use". If its not too much trouble could you expand a little on this?

Thanks again for the reply.

Chris
 
If you are using the Me shorthand for form referencing, Access may be looking at your master form, rather than the form you use as a dialog. Try spelling out the full form name.
 
thanks for the reply neileg.

Im already using the full names in if statments that are referencing the results of an optionValue frame. Im not using the ME.reference anywhere in the project at present.

Thanks again for the advice

PS aint it grim up north today??!!
 
Yeah, it was pretty grim yesterday but better today!

Have you declared the relevant variables in the right places? If you are relying on implicit declaration, might this cause a problem. Try declaring the variables as public when you open the master form.
 
thanks for the reply. Could you explain a little more about declaring the forms as public declarations. Wher and how exactly would i go about doing this?
 
It's not the form that is public but the variable. Variables are normally private and live for the life of the VB routine they are called in. Access does not, by default, require the variables to be declared.

If you want a variable to live outside of a single routine, you must declare them as public. They are then available to any routine you run, and hold their values when database objects are opened and closed.

You need to declare them in a module, and if your db does not have a module, then you can create one just for this purpose. The syntax is simple, e.g.

Public ParentDir As String

Good luck
 

Users who are viewing this thread

Back
Top Bottom