# Access: Hide an already open window with VB or Macro



## firestormer (Sep 16, 2005)

I need to hide a window thats already open using some VB or a macro. 

Anyone know how?

Thanks


----------



## OBP (Mar 8, 2005)

Which type of window?
Is it a Form/Report or an actual Access system window?


----------



## firestormer (Sep 16, 2005)

HI OBP i thought it would be you who'd reply.

Yup its just a form in access. 
I know how to hide a form from open using a macro but the form needs to be visable at first then hide.

Is there any DoMenuItem VB to do the Window > Hide > [Form Name] ?

Also on a completely different topic do you know how to get access to select a specific item in a list box on a form?

Thanks


----------



## OBP (Mar 8, 2005)

firestormer, you can use the direct 
FormName.Visible = False 
to hide a form, where FormName is the name of your form. It depends on where you are trying to hide it from.
The second question I am not clear on, does the user select an item and you want to know what it is?
Or do you want to run through the List "Source" and match to a value?


----------



## firestormer (Sep 16, 2005)

Great the code works Thanks

Second Question.

The list box is on a form and is set up so that when an item on the list box is selected the form goes to the appropriote record.

The problem is if the user uses the mouse wheel, keyboard ir navigation buttons to change record. When this happens the item selected on the list box remains the same thus possible confusing the user.


----------



## OBP (Mar 8, 2005)

This sounds like the List Box is Unbound?


----------



## firestormer (Sep 16, 2005)

Sorry for the delay, i didnt get an email that you'd posted.

The list box is unbound.


----------



## OBP (Mar 8, 2005)

For the list box to retain a prior selection it has to be "bound" to a Field in the form's underlying table or query, otherwise there is no way for Access to remember what selection you have made.


----------



## firestormer (Sep 16, 2005)

If its bound then when an item on the list is selected the record will be altered to that item on the list.

This list is a list of the records in that form. By selecting the record form the list the form goes to that record. BUT when the record in view is changed by other means (keyboard navigation buttons) the list dosnt reflect that move.

I have attatched the relevent sections of the DB.


----------



## OBP (Mar 8, 2005)

Is this what you want it to do?


----------



## firestormer (Sep 16, 2005)

Yeah, what did you do?


----------



## OBP (Mar 8, 2005)

Added a line of VB code to the On Current event procedure.


----------



## firestormer (Sep 16, 2005)

GREAT, thanks.

This project is nearly reaching an end THANK GOD!

if just got to make some final tweaks and thats it. 

Thanks for all your help.


----------



## OBP (Mar 8, 2005)

firestormer, my pleasure, see you on the next one.


----------



## firestormer (Sep 16, 2005)

Im back (already), I realy ought to buy a book on VB and Access.

Say i have a form (From1) it has fields A and B where A is the primary key.
I have another form (Form2) it has fields B and C where B is the primary key.

I want to create a button in Form1 which when clicked will open Form2 and go to the reocrd where B in Form 2 is the same as the B shown in Form1.

What VB will i need? I figure the VB will need to go in Form1 and this is what i have so far:

Private Sub Command1_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"
DoCmd.Minimize

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord

After that im stuck


----------



## OBP (Mar 8, 2005)

If you use the Toolbox Button Wizard the first question it asks after you select the Form to open is

"Open the Form and show all Records" - this is the default

the option above it is the one that you want

"Open The Form and find specific data to display"

when you tick that one the Wizard will ask which fields you want to match.
Job done.


----------



## firestormer (Sep 16, 2005)

Funny, ive been using Access for 3 years now and ive never noticed that.

I was blind and now i see.

Thanks, (again(again))


----------



## firestormer (Sep 16, 2005)

OK this is getting embarrasing.

After further examination this isnt what i want. This method filters the form. I dont want it to filter the form but just to go to the matching record.


----------

