Search not working after 1 try

gomes.

Registered User.
Local time
Today, 11:12
Joined
Feb 14, 2008
Messages
27
So basically I click the search students button (circled red), and the window pops out fine and lets me searches the students. Okay i searched for the student and its a success.


The problem is, 2 windows appear now, the original main menu form where I clicked search students, and now the searchstudent2 form which displays the details of the student i searched for.
The problem is, if I dont close the searchstudent2 form, if I go back 2 main menu, and click search, the search doesnt work and instead it just goes back immediately to the searchstudents2 form, instaed of letting me type in a studentID.

Also My friend's database, could open the form in just one window, not 2.when he clicks search only 1 window appears, the main menu one goes off, how would I do that?

Cheers.
 
The problem is, if I dont close the searchstudent2 form, if I go back 2 main menu, and click search, the search doesnt work and instead it just goes back immediately to the searchstudents2 form, instaed of letting me type in a studentID.
Sounds like the form is sourced from a query. From the picture, it looks like that too. What's the code behind the button? If you're just using an openform command to open the object, and then relying on the query to provide a parameter input, you might be better off just writing some syntax that requires an input value within the "filter" section. Maybe you could use an input box for this?

That would, for sure, guarantee you a popup to input the criteria everytime you click the button.
 
Simple Software Solutions

I assume your search student is a Modal Popup form that runs the search. If successful it opens up the search results form to display the matching record.

Make this a Modal Popup form and on this form have a Use Me button and a Cancel button. If you click Cancel it simply closes the form. If you choose Use Me it uses the information for your main form, in which ever way you have coded it to do so. Close this form also when they click this button.

I assume that you run the search query on your first form to decide whether to open the search results form.

what you need to do is to make sure that you also close the search form before you use the main form.

Access has a function called IsLoaded(Form Name)

So when you open your main form you can add the commands to the OnLoad Property of the form

If IsLoaded("FrmSearchForm") Then

DoCmd.Close "FrmSearchForm"

Endif

If IsLoaded("FrmSearchResults") Then

DoCmd.Close "FrmSearchResults"

Endif

This will ensure that if either of the 2 underlying forms are open it will close them. So when you close the main form you will be returned to the Main Menu screen.

Public Function IsLoaded(strFormName As String) As Boolean
'Purpose :To check wether a given form is loaded or not
' :When referring to forms by name, the form must be open or access returns an error

Dim i As Integer
For i = 0 To Forms.Count - 1
If (Forms(i).Name = strFormName) Then
IsLoaded = True
Exit For
End If
Next
End Function


CodeMaster::cool:http://www.icraftlimited.co.uk
 
I like the website David. Simple for searching, but not too unvailing.

What's with the phone numbers anyway? Weird!!
 
Simple Software Solutions

Adam

What do you mean about phone numbers???

David

Thanks for comments about the website. This was my first attempt
 
thanks I solved the problem, ised a macro (open and closed form)
 

Users who are viewing this thread

Back
Top Bottom