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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Office Access can't find form...

Status
Not open for further replies.

superljl

MIS
Apr 30, 2007
7
US
I've got a form with a listbox built on the fields of a table. On the After Update event, I've got this code:

Private Sub lstQueries_AfterUpdate()
Dim LinkCriteria As String

On Error GoTo Err_lstQueries_Afterupdate

LinkCriteria = "qry" & lstQueries.Value
Forms!frmInv.RecordSource = LinkCriteria
DoCmd.OpenForm "frmInv"

Exit_lstQueries_AfterUpdate:
Exit Sub

Err_lstQueries_Afterupdate:
MsgBox Err.Description
Resume Exit_lstQueries_AfterUpdate


End Sub

When I choose from the list box, I get the "Microsoft Office Access can't find form..." message. I actually had this exact proc working until I changed the name of the form...

Any help would be sincerely appreciated! Thanks!

Lori
 
You must open the form before it becomes part of the Forms collection:

[tt]DoCmd.OpenForm "frmInv"
Forms!frmInv.RecordSource = LinkCriteria[/tt]


 
Then you've misspelled the name of the form or named it to something other than what you think you have, probably. What's the name of the form now?

TMTOWDI - it's not just for Perl any more
 
Remou: It was working before without opening the form first. I don't want to see the form with no data in it.

Adalger: The name of the form now is frmInv. I've looked everywhere I can think of that might have the wrong name and I can't find any instances of the wrong name. I'm stumped.

If I remove the recordsource line, it'll open just fine.
 
How are ya superljl . . .
superljl said:
[blue]Remou: It was working before without opening the form first.[/blue]
Then your saying the form was already open! . . . Otherwise [blue]Remou[/blue] is right!

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
The code was working (before I renamed the form) linking the recordsource BEFORE opening the form. I swear!

The recordsource query I was attaching (a parameter query) would run, I'd answer the question, THEN the form would open. Now, if I switch those two lines in the code, the form opens first, then the question pops up.
 
You can open the form hidden and make it visible after setting the RecordSource.
 
Thanks, Remou. I did play around with that, but the form kept opening in design view(?). Here's the code I used:

DoCmd.OpenForm "frmInv", acHidden

Is that incorrect? And, can you tell me, once the form is hidden, what's the code for making it visible? I don't want to open it again and requery...

I'm beginning to think I've got a corrupt database that compact and repair can't fix ('cause I've tried that, too).
 
Ok. I think it is much better that you open the form using the Where argument of OpenForm. If this is not possible, you need to put acHidden in the right place:

[tt]DoCmd.OpenForm "frmInv", , , , , acHidden[/tt]
 
Okay, thanks! I haven't messed around with OpenForm much and didn't realize I was putting it in the wrong place!

Now, how do I "unhide" it?
 
You can set the Visible property:

[tt]Forms!frmInvoice.Visible = True[/tt]
 
Thanks for all your help, everyone, but I created a new database with my main table and was able to get back to where I was before the "renaming the form" debacle.

I can now link the recordsource to the form without opening the form first.

Making the form hidden then visible wasn't working for me because I'd get a re-query, and since my query was a parameter query, the question would be asked twice. Maybe this behavior was part of the corruption.

Access Help regarding the recordsource property notes that "changing the record source of an open form or report causes an automatic requery of the underlying data" which, to me, means that you don't necessarily have to open the form to change the recordsource, and I've found out you don't. My original mdb must have been corrupt in some way...

Thanks again!
 
If it's open, I don't know how it's being opened.

Here's my process:

I launch Access, I open the mdb, I launch my switchboard and choose an option from a listbox. My listbox choice [AfterUpdate event] sets the recordsource (a parameter query) for my results form, the parameter input box pops up and I type in the parameter I want, then the form opens. There's a command button on the results form that closes the form and returns to the switchboard. I click it, closing the form. I choose another option from the listbox and the same cycle happens all over again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top