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!

OLE Object Erros on subforms

Status
Not open for further replies.

dgirl1010

Technical User
Jul 14, 2006
20
0
0
US
I have a calendar button that the user can select to choose a date on several of my forms. I'm using VBA to tell the calendar form which date to default to, as well as whcih field to send the selected date to. It works perfectly in all spots except one, where the button is on a subform. I have another form with this same button on a subform there and it works correctly. I'm not sure what I'm missing here.

The error I'm getting on clicking the button is "The object you referenced in the Visual Basic procedure as an OLE object isn't an OLE object."

The code that works:
[Global Code].stSelectDate = "DueDate"

If (Eval("[Forms]![OpsProject]![OpsTask].Form!txtDueDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![OpsProject]![OpsTask].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If

The code that doesn't work:
[Global Code].stSelectDate = "ConfigDtlsEffDate"

If (Eval("[Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtEffectiveDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If
 
I posted this late Friday, hoping someone can help me today. Thanks!
 
Perhaps this ?
Forms!Calendar!OleCalendar.Value = [Forms]![Config_frm]![ConfigDetailsSub_frm].Form![!]txtEffectiveDate[/!]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
BTW, which line of code highlighted when in Debug mode ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I caught that too (typo, sorry). I actually have it as that already and no luck. :(

This is the line that is highlighted when I debug:
If (Eval("[Forms]![Config_frm]![ConfigDetailsSub_frm].txtEffectiveDate Is Not Null")) Then

I've also tried pulling out the [Config_frm] portion and just opening the subform (stand alone) and the code works fine then. It's only when it's open in the main form that it gets hosed. I'm stumped.
 
Just tried this too, with no luck:

If (Eval("[Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtEffectiveDate Is Not Null")) Then
 
I got it! I knew it was something simple, and it was. I had to change the name of the form to ConfigDetailsSub_frm. I still had it as the default name (DOH!). Changed that and this works like a charm. Thanks for the help! :)
 
Have a look here:

You may try to play with the expression builder (loaded forms) to discover the proper syntax.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top