Meaning of error message?

N

Niniel

Hello,

What does this error message mean, and what do I have to do to get rid of it:

"Object doesn't support this property or method".

What I am trying to do is put a button onto a subform that allows the user
to put in the time by clicking number keys with the mouse rather than typing
it. The button launches a little time-picking form I found elsewhere, but
when I try to save the time to my form, I get that message.

Here's the code that I adapted from the sample db:

Private Sub cmdOk_Click()
On Error GoTo Err_CmdOK_Click

Forms!frmBrowseApplications!sfrmOptions.Forms!Start_Time.Value =
Me.txtTime.Value
DoCmd.Close acForm, "frmTime"

Exit_CmdOK_Click:
Exit Sub

Err_CmdOK_Click:
MsgBox Err.Description
Resume Exit_CmdOK_Click

End Sub

frmBrowseApplications is my main form, on which resides the subform
sfrmOptions, which hosts the button that calls the time form. On the time
form is an "OK" button, and the code is attached to it.

What am I doing wrong here?

Thank you.
 
N

Niniel

No, I still get the error message.

Plus, I swear the code is exactly the same as in the sample DB except that I
changed the path to the form the button is on. That seems to indicate that
I'm referencing my form incorrectly, but I can't figure out where the error
is.
 
S

Stefan Hoffmann

hi Niniel,
Private Sub cmdOk_Click()
On Error GoTo Err_CmdOK_Click

Forms!frmBrowseApplications!sfrmOptions.Forms!Start_Time.Value =
Me.txtTime.Value
You can write this shorter:

sfrmOptions.Forms!Start_Time.Value = txtTime.Value
What am I doing wrong here?
Is Start_Time a field or a control? If it is a field, the following
should work:

sfrmOptions.Forms![Start_Time] = txtTime.Value


mfG
--> stefan <--
 
N

Niniel

It's a text field [doesn't matter if it's formatted as a date/time field,
does it?]. The name is actually "Start Time" with a space [I know, bad bad
bad], but I observed Access changing that to Start_Time on its own [in the
VBA editor], so that's why I wrote it this way.

Anyway, just using sfrmOptions.Forms!Start_Time.Value gives me an "object
not defined" error. Writing it either with or withough [] doesn't seem to
make any difference at all.




Stefan Hoffmann said:
hi Niniel,
Private Sub cmdOk_Click()
On Error GoTo Err_CmdOK_Click

Forms!frmBrowseApplications!sfrmOptions.Forms!Start_Time.Value =
Me.txtTime.Value
You can write this shorter:

sfrmOptions.Forms!Start_Time.Value = txtTime.Value
What am I doing wrong here?
Is Start_Time a field or a control? If it is a field, the following
should work:

sfrmOptions.Forms![Start_Time] = txtTime.Value


mfG
--> stefan <--
 
N

Niniel

Got it!

Forms!frmBrowseApplications.sfrmOptions![Start Time].Value = Me.txtTime.Value

is what works. I can delete "Value" from the right side of the equation, and
it still works.

Thanks for the assistance!

Niniel said:
It's a text field [doesn't matter if it's formatted as a date/time field,
does it?]. The name is actually "Start Time" with a space [I know, bad bad
bad], but I observed Access changing that to Start_Time on its own [in the
VBA editor], so that's why I wrote it this way.

Anyway, just using sfrmOptions.Forms!Start_Time.Value gives me an "object
not defined" error. Writing it either with or withough [] doesn't seem to
make any difference at all.




Stefan Hoffmann said:
hi Niniel,
Private Sub cmdOk_Click()
On Error GoTo Err_CmdOK_Click

Forms!frmBrowseApplications!sfrmOptions.Forms!Start_Time.Value =
Me.txtTime.Value
You can write this shorter:

sfrmOptions.Forms!Start_Time.Value = txtTime.Value
What am I doing wrong here?
Is Start_Time a field or a control? If it is a field, the following
should work:

sfrmOptions.Forms![Start_Time] = txtTime.Value


mfG
--> stefan <--
 
N

Niniel

Now I have a different problem though - I need a variable instead of a
hard-coded path to just one field.

I want to call the time form from various subforms on my main form, and need
data written back into more than one field per form, too.

Judging from my date picker form, that means I'll need a module... :(
 
S

Stefan Hoffmann

hi,
Now I have a different problem though - I need a variable instead of a
hard-coded path to just one field.
I want to call the time form from various subforms on my main form, and need
data written back into more than one field per form, too.
Can you give me to examples with some names and code, cause i'm not sure
if i understand your intention.

Instead of accesing a control by its name, you can use

Me("NameOfControl")

or

Form("NameOfControl")

Maybe it helps.

mfG
--> stefan <--
 
N

Niniel

Yes, of course.

Right now, I am working on a main form called frmBrowseApplications. On it
is the subform sfrmOptions, with the two fields [Start Time] and [End Time].

I also want to use the time form on another main form called
frmActivityApplicationForm, also with the subform sfrmOptions and the two
fields [Start Time] and [End Time].

The first form is for editing existing records, and the second one for
adding new ones.

Next to the time fields I have placed buttons to call the time form,
frmTime. And by clicking <OK> on the time form, the time is to be written to
the date field/s.

Does this explain things clearly enough?
 
N

Niniel

Woo-hoo!

I managed to adapt Allen Browne's excellent popup calendar
http://allenbrowne.com/ser-51.html for my purposes, and therefore avoid this
issue altogether.


Niniel said:
Yes, of course.

Right now, I am working on a main form called frmBrowseApplications. On it
is the subform sfrmOptions, with the two fields [Start Time] and [End Time].

I also want to use the time form on another main form called
frmActivityApplicationForm, also with the subform sfrmOptions and the two
fields [Start Time] and [End Time].

The first form is for editing existing records, and the second one for
adding new ones.

Next to the time fields I have placed buttons to call the time form,
frmTime. And by clicking <OK> on the time form, the time is to be written to
the date field/s.

Does this explain things clearly enough?


Stefan Hoffmann said:
hi,

Can you give me to examples with some names and code, cause i'm not sure
if i understand your intention.

Instead of accesing a control by its name, you can use

Me("NameOfControl")

or

Form("NameOfControl")

Maybe it helps.

mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top