Search Form

Tay

likes garlic
Local time
Today, 16:19
Joined
May 24, 2002
Messages
269
On my main form which lists scheme details, I have a button which opens a search form. This has cascading combos on it. Once the user has selected what they want, they press a button and then return at the record they chose on the main form.
However, I realised that the search form could be used on 4 other forms too.
Rather than having 5 copies of the same search form, it would make sense to try to get the one search form to realise which form it was supposed to open. That's where I come unstuck, as I'm not sure how to go about this.
Here is what I want to happen.
from Main form - open Search form - find record - go to that record on Main form
from Enter Scheme form - open Search form - find record - go to that record on Enter Scheme Form etc.
But I don't know how I can get the search form to go to the correct record on the correct form (ie, the form which opened the search form from it).
If anyone could advise me how to go about this, I'd be very happy indeed.
 
i) Have a public string variable declared in a module (i.e. strFormName)

ii) Before calling the search form, assign Me.Name to strFormName

ii) When re-opening the calling form use DoCmd.OpenForm strFormName, acNormal
 
could your mail me a copy of that I wanted to do the same thing?
 
What exactly are you after - an example of cascading combos, or were you referring to the Search form stuff?
 
search form..but wouldnt mind looking at cascading combos...im always interested in looking at databases
 
Mile-O-Phile

Thanks for your response to my problem. However, my coding skills are basic to say the least, so if you could give me a little more to go on, that would be brilliant.

Chewy

I'll email you with an example of the search form (with cascading combos) at lunchtime.
 
Okay, in a module (new or existing) put this line near the top, outwith any function or routine.

Public strFormName as String


On your form, I'm guessing you have a button that you click that opens up the search form, so:

Code:
Private Sub YourCommandButton'sNameHere_Click()
   strFormName = Me.Name
   DoCmd.Close acForm, "YourCallingFormNameHere"
   DoCmd.OpenForm "YourSearchForm'sNameHere", acNormal
End Sub

Finally, on your search form's close button, this code:

Code:
Private Sub YourCloseingCommandButton'sNameHere_Click()
   DoCmd.Close acForm, "YourSearchForm'sNameHere"
   DoCmd.OpenForm strFormName, acNormal
End Sub
 
Thanks for your help - it's appreciated. Going well - now just trying to find a way to link to get the form to open at a specific record.:) ;) :)
 
In the same module, make a public variable to store the record ID and assign the record ID to it every time the user selects a records, that way you can filter with it.
 

Users who are viewing this thread

Back
Top Bottom