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

IsLoaded function not working

Status
Not open for further replies.

WalkieTalkie

Technical User
Feb 15, 2002
91
NZ
I want a form to go to a new record, and fill in the ID from another form that is open at the same time. There are two forms that this form can take the ID from so I have been trying to use the IsLoaded function to determine which form is open. Here is my code:
Code:
DoCmd.GoToRecord , , acNewRec
    If IsLoaded("fmNewBooking") Then
        Me![ClientTourID] = Forms![frmNewBooking]![ClientTourID]
    End If
    If IsLoaded("fmEditBooking") Then
         Me![ClientTourID] = Forms![frmEditBooking]![ClientTourID]
    End If
It will only work if I take out the IsLoaded. Any ideas why this is not working? Thanks in advance.
 
why this is not working?
What happens ?
Error message ? Unexpected behaviour ? Computer crash ? ... ?

Anyway, I'd use this instead of an UDF:
If CurrentProject.AllForms("fmNewBooking").IsLoaded Then ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, I should have provided more info.

The form opens at a new record, but the ClientTourID is null, so I end up with an error 3101:...cannot find a field in tblClientTour with key matching fields...Its not picking up the ClientTourID from frmEditBooking. I hope that makes sense?

 
Spelling issue ?
If IsLoaded("f[!]r[/!]mNewBooking") Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
YOU'RE KIDDING ME!!!!!

No, unfortunately you are not. I'm not going to make you pity me even more than you already do by telling you how long I have been trying to make that work! How did I not see that?! Anyhow - thank you for the time you have spent on that, sorry if you had better things to be thinking about!
Regards
Miranda
 
Miranda, if you use Option Explicit in your code modules this kind of error is detected right away. Option Explicit forces you to declare your variables, but perhaps more importantly points out syntax - spelling - errors. If you use Option Explicit then:

"How did I not see that?! "

would not happen. You would see it.

Gerry
 
You would see it
Sorry Gerry, but I don't think so as the spelling error was inside a quoted literal ...
 
Ooops. My bad. I take that back. PHV is quite correct. It is a quoted literal.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top