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

Runtime Error 438 - Works on one form and not another

Status
Not open for further replies.

TheFitz

Programmer
Dec 18, 2003
140
0
0
GB
Hi All,

Hopefully this won't be too confused.

I have a "Register" Form to book people in and out using a Bar code etc. This form is called "frmBookInOut".

When loading from the Main Menu, this form uses now() to calculate from.

If a different date to day is required, another form is loaded up, the new date selected and then the "frmBookInOut" is loaded.

Both of the above processes use the same code as shown below:

Code:
...
    DoCmd.OpenForm "frmBookInOut", acNormal
    Forms!frmBookInOut.txtDate = Format([COLOR=#EF2929][b]Now()[/b][/color], "DD-MMM-YYYY")
...

Obviously, the part in RED is different, but the rest of the code is exactly the same (I've even copied from 1 to the other to check!)

Interestingly, running from the "Main Menu" it comes up with the Error 438 - Obj Not Supported error whereas from the date selectio it works happily.

Anyone got any ideas and I am COMPLETELY lost. . . . .

thanks for any pointers,

Fitz


Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
If something obvious and basic suddenly does not work, I would check my References if I have any of them MISSING.

Have fun.

---- Andy
 
Hi Andy,

Good call, however, it's not that. I've checked another copy of the same system and it's working fine. . . . .

References are exactly the same.

F.

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
I have seen issues where due to timing, the form may not be 'ready' when you try to set the txtDate field.
Does the problem ALWAYS happen under certain circumstances, or SOMETIMES? If Always, I would put a breakpoint where you set the date, pause a second, then resume.
Also, does the form being opened have a recordsource, and is txtDate bound to one of the fields in the recordsource?

The speculative judgment of the quality of an answer is based directly on … what was the question again?
 
Agreed. I like your thinking, but no :-(

The "frmBookInOut" form is a single form which has a number of "txtDate" controlled list boxes, however, I have tried waitng for a few seconds and trying again and to no avail.

Further investigations:

I've set the default value of "txtDate" to be =format(now(),"DD-MMM-YYYY") and run the form standalone and it works correctly.

With this amendment installed, I've rerun the code (at the top) and it now fails on the next line down.

To me, this suggests that the "frmMainMenu" can't tall to the "frmBookInOut". I guess it can't be the "frmBookInOut" which is at fault given that another form does exactly the same process, however, on frmMainMenu, the only piece of code that tried to manipulate another form like this is on this button????

Very confused!!! :-S

Thanks for the suggestions, keep them coming . . . .

Thanks

F.

(PS- I'll post here if I work it out, even if it's my own stupidity!!!)

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
What section is txtDate located in? Header, Detail, etc.?
Is the field bound?
Does the opened form have a RecordSource?
Re "...it now fails on the next line down." what is the next line? Another Date setting?

I just tried your code, but no problem.....

The speculative judgment of the quality of an answer is based directly on … what was the question again?
 
Sorry, I should have shown the rest of the code, I had put it in the top piece and then removed it to save over complicating it.

To answer your questions:

What section is txtDate located in? Header, Detail, etc.? - Detail
Is the field bound? - No - Unbound
Does the opened form have a RecordSource? - No, no record source, it shows 4 lists of people:
Those who are "Booked In" (lstRegister)
Those who are "Not Booked In" (lstAtRehearsals)
Those who are "Not expected each week but are on the register" (lstNotAtRehearsals)
Plus a few other fields which are all unbound.

Re "...it now fails on the next line down." what is the next line? Another Date setting? Full code of this button (excluding comments is shown below:

Code:
Private Sub cmdRegister_Click()

    DoCmd.OpenForm "frmBookInOut", acNormal
    Forms![frmBookinout]![txtDate] = Format(Now(), "DD-MMM-YYYY")
    Forms![frmBookinout]![lstAtRehearsals].Requery
    Forms![frmBookinout]![lstRegister].Requery
    Forms![frmBookinout]![lstNotAtRehearsals].Requery
    Call CheckStats

DoCmd.Close acForm, "frmMainMenu"

End Sub

For reference "CheckStats" basically counts those in, not in etc etc and updates other fields on the form.

I've skipped the code down to CheckStats and just run that (which is located in a separate function) and this works correctly too!!! Check stats also updates 5 of the fields on the frmBookInOut, so the more I look at it, the more it suggests a problem with frmMainMenu (the calling form).

Hair-loss is increasing!!! :-S

Thanks for the suggestions,

F.


Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Here is a quick idea (gotta run an errand): pass the date as an OpenArg, then in the Form Load event, set txtDate.
Short term maybe a solution; longer term you can try to figure out original problem... Back in an hour...
Code:
DoCmd.OpenForm "frmBookInOut", acNormal, , , , , Format(Now(), "DD-MMM-YYYY")

The speculative judgment of the quality of an answer is based directly on … what was the question again?
 
Hey all,

I'm still struggling with this one.

As a temporary solution I've set txtDate as =Format(Now(), "DD-MMM-YYYY") in it's default value which has temporarily fixed the problem.

It still allows the ability to change the data via the other "working" form.

I could leave this solution in as the final fix, however, it's not a case of trying to work out exactly WHY it's not working. . . . .

hmmmmmm . . . .

Thanks for your efforts thus far,

F.

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top