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

Attention All Programmers: SOS SOS SOS SOS

Status
Not open for further replies.

jjdoro

Technical User
Nov 24, 2002
16
US
I have a main form called Interviewers and a subform called Ratings. The subform also has a command button that is a date picker. The field it updates on the subform is called Date2. The On Click property of the command button is set with this: =OpenCalendar("Ratings","Date2",1.792,3.439). When I click on the command button
I get a run time error 2450 cannot find the "Ratings" form. Then When I debug it, it goes to this part of the code: Set frm = Forms(strForm) Below is the code from the module.
The Date Picker works great as long as it is on a form by it self. It's when I put it on a subform that I get the error. Thanks any assistance is super appreciated

Option Compare Database
Option Explicit
Dim ctrl As Control
Dim frm As Form
Const centimeter = 567

Function OpenCalendar(strForm As String, strCtrl As String, intLeft, intTop)
Set frm = Forms(strForm)
Set ctrl = frm(strCtrl)
frm("msCal").Visible = True
frm("msCal").Left = intLeft * centimeter
frm("msCal").Top = intTop * centimeter
frm("msCal").Value = Date
End Function

Function CloseCalendar()
frm(ctrl.Name).SetFocus
frm("msCal").Visible = False
End Function

Sub SetDate()
frm(ctrl.Name).Value = frm("msCal").Value
frm(ctrl.Name).SetFocus
frm("msCal").Visible = False
End Sub
 
The error you're getting, I believe, is due to the fact that your ratings form is not actually open in a window, and hence not part of the forms collection.

I don't know if you'll be able to get away with it, but try passing a reference to the "form within the subform" control, such as follows:

...
dim frm as form
frm = forms!interviewers!<name of subform control>.form
...

As a result, your function call then becomes the following:

=OpenCalendar(frm,&quot;Date2&quot;,1.792,3.439)

Like I said, I don't know if it'll work, but you could try it - never hurt anyone before ... except if you're rock climbing. :p

Greg


Boss quote from an office meeting: We're going to continue to have these meetings until we figure out why no work is getting done ...
 
Greg, I'm a little confused as to where I should place the code:
dim frm as form
frm = forms!interviewers!<name of subform control>.form

 
In the on click event of your button, instead of setting the click event =OpenCalendar (etc etc), use an event procedure, and put the 2 lines of code right before your function call.

dim frm as form
set frm = forms!interviews ... etc

OpenCalendar frm, ...

HTH

Greg


Boss quote from an office meeting: We're going to continue to have these meetings until we figure out why no work is getting done ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top