Method or Data Member Not found

L

lsgKelly

I have the following code attached to a button on my form:

Private Sub Command70_Click()
[color blue]
Me.gnotes.Locked = False
Me.gnotes = Now() & "--" & CurrentUser() & "--" & [Add] & vbCrLf &
"-----------------------------------------------------------------------------------------------------------------------------------------------"
& vbCrLf & Me.gnotes
Me.gnotes.Locked = True
Me.Add = Null
[/blue]

End Sub

I'm getting the error at the Me.gnotes.Locked = False line.

Any ideas on how I can get this to work?

Thanks,

Kelly
 
S

Stuart McCall

lsgKelly said:
I took out the blue comments and I'm still getting the same error. Any
other
ideas? It's still stopping at the .locked comment.

Stuart McCall said:
lsgKelly said:
I have the following code attached to a button on my form:

Private Sub Command70_Click()
[color blue]
Me.gnotes.Locked = False
Me.gnotes = Now() & "--" & CurrentUser() & "--" & [Add] & vbCrLf &
"-----------------------------------------------------------------------------------------------------------------------------------------------"
& vbCrLf & Me.gnotes
Me.gnotes.Locked = True
Me.Add = Null
[/blue]

End Sub

I'm getting the error at the Me.gnotes.Locked = False line.

Any ideas on how I can get this to work?

Thanks,

Kelly

The problem is the line before that. [color blue] is not VBA syntax.
Neither
is [/blue]. Either comment out both those lines or delete them.

What sort of control is gnotes? And is gnotes really the exact name of the
control?
 
L

lsgKelly

gNotes is a Memo field, and yes, that is the name of the control.

Stuart McCall said:
lsgKelly said:
I took out the blue comments and I'm still getting the same error. Any
other
ideas? It's still stopping at the .locked comment.

Stuart McCall said:
I have the following code attached to a button on my form:

Private Sub Command70_Click()
[color blue]
Me.gnotes.Locked = False
Me.gnotes = Now() & "--" & CurrentUser() & "--" & [Add] & vbCrLf &
"-----------------------------------------------------------------------------------------------------------------------------------------------"
& vbCrLf & Me.gnotes
Me.gnotes.Locked = True
Me.Add = Null
[/blue]

End Sub

I'm getting the error at the Me.gnotes.Locked = False line.

Any ideas on how I can get this to work?

Thanks,

Kelly

The problem is the line before that. [color blue] is not VBA syntax.
Neither
is [/blue]. Either comment out both those lines or delete them.

What sort of control is gnotes? And is gnotes really the exact name of the
control?
 
S

Stuart McCall

lsgKelly said:
gNotes is a Memo field, and yes, that is the name of the control.
<snip>


Yes but what is the type of the _control_ (not the field it's bound to) ? Is
it a textbox or a label? I would expect that error if it were a label. If a
textbox then that line shouldn't fail.

The only other thing that springs to mind is that the database may be
corrupted. Try importing everything into a new database and see if the error
clears up (always worth a try).

Other than that, I'm stumped.
 
L

lsgKelly

Thanks Stuart,

Okay, I got this one to work. Evidently, the name of the control and the
label name have to be the same. :)

Private Sub Command70_Click()
Me.gNotes.Locked = False
Me.gNotes = Now() & "--" & CurrentUser() & "--" & vbCrLf &
"-----------------------------------------------------------------------------------------------------------------------------------------------"
& vbCrLf & Me.gNotes
Me.gNotes.Locked = True
End Sub

This isn't doing exactly what I want it to do. I would really like it to
enter in the date, the user name, then allow the person to type something.
As soon as they move away from the control, I would like it to lock it up
again. Right now, this is what shows up in the box:

4/17/2009 8:28:55 AM--Admin--
-----------------------------------------------------------------------------------------------------------------------------------------------

and it won't let me type anything.

What am I missing?

Thanks again,

Kelly
 
S

Stuart McCall

Answers inline:

lsgKelly said:
Thanks Stuart,

Okay, I got this one to work. Evidently, the name of the control and the
label name have to be the same. :)
Because you followed that with a smiley, I'm going to assume you know this
isn't the case.
Private Sub Command70_Click()
Me.gNotes.Locked = False
Me.gNotes = Now() & "--" & CurrentUser() & "--" & vbCrLf &

If you want just the date and not the time portion, use the Date() function
instead of Now().
"-----------------------------------------------------------------------------------------------------------------------------------------------"
& vbCrLf & Me.gNotes
Me.gNotes.Locked = True
Move the above line to the control's AfterUpdate event. This event only
fires if the user makes a change, then tries to move away from the control,
which is exactly the behaviour you describe.
<snip>
 
L

lsgKelly

This works! Except one thing, once it puts in the Date/Time/Username, it
doesn't go to the end of the data so they are able to type. You actually
have to click in the box where you want to start typing. Is there a way to
move the cursor to the end of the data, so when they start typing, it begins
after the Date/Username?
Because you followed that with a smiley, I'm going to assume you know this
isn't the case.

I'm serious. that is exactly what I did. The label was "Comments" and the
field name is gNotes. As soon as I changed "Comments" to gNotes, I no longer
got the error. I put in a smiley because I couldn't believe that was why I
was getting the error. i thought maybe it was something I should know!

Really appreciate your help! Thank you!

Kelly
 
S

Stuart McCall

lsgKelly said:
This works! Except one thing, once it puts in the Date/Time/Username, it
doesn't go to the end of the data so they are able to type. You actually
have to click in the box where you want to start typing. Is there a way
to
move the cursor to the end of the data, so when they start typing, it
begins
after the Date/Username?

Me.gnotes.SetFocus
Me.gnotes.SelStart = Len(Me.gnotes.Text)
I'm serious. that is exactly what I did. The label was "Comments" and
the
field name is gNotes. As soon as I changed "Comments" to gNotes, I no
longer
got the error. I put in a smiley because I couldn't believe that was why
I
was getting the error. i thought maybe it was something I should know!

If (as you suggest) you name a control, say, Fred, then try to name a label
on the same form Fred, Access will (quite rightly) not allow it.
Really appreciate your help! Thank you!

You're welcome. Glad I could help.
 
L

lsgKelly

ONE more thing... I hope. This is turning out to be more trouble than it is
worth!

Okay, so here is the code I have:

Private Sub Command69_Click()
Me.gNotes.Locked = False
Me.gNotes = Now() & "--" & Environ("Username") & "--" & vbCrLf
Me.gNotes.SetFocus
Me.gNotes.SelStart = Len(Me.gNotes.Text)
End Sub

It works the first time I hit the button, but the second time, it puts the
date/time/username at the TOP of the memo field, and pushes the rest down.
That would be fine, except the cursor goes to the bottom of the memo
field...so it looks like this:

4/17/2009 2:00:16 PM--kmccracken--
4/17/2009 2:00:09 PM--kmccracken--
working 123_

This would be okay if the cursor ended up at the end of the first line... I
would rather it go to the end of the field, add the next date and time and
then it would work.

Is there something I can put in the code to make it add the next date and
time below the first set of data, instead of at the top?

Thanks
 
S

Stuart McCall

lsgKelly said:
ONE more thing... I hope. This is turning out to be more trouble than it
is
worth!

Okay, so here is the code I have:

Private Sub Command69_Click()
Me.gNotes.Locked = False
Me.gNotes = Now() & "--" & Environ("Username") & "--" & vbCrLf
Me.gNotes.SetFocus
Me.gNotes.SelStart = Len(Me.gNotes.Text)
End Sub

It works the first time I hit the button, but the second time, it puts the
date/time/username at the TOP of the memo field, and pushes the rest down.
That would be fine, except the cursor goes to the bottom of the memo
field...so it looks like this:

4/17/2009 2:00:16 PM--kmccracken--
4/17/2009 2:00:09 PM--kmccracken--
working 123_

This would be okay if the cursor ended up at the end of the first line...
I
would rather it go to the end of the field, add the next date and time and
then it would work.

Is there something I can put in the code to make it add the next date and
time below the first set of data, instead of at the top?
<snip>

Ok let's start afresh. Here's how I'd write this:

Private Sub Command69_Click()
With Me.gNotes
.Locked = False
.Value = .Value & vbCrLf & Date() & "--" & Environ("Username") & "--"
.SetFocus
.SelStart = Len(Me.gNotes.Text)
End With
End Sub

Notice I'm adding to the end of the existing data, using .Value = .Value &
vbCrLf & ...
 
L

lsgKelly

that's it!!! Thank you so much for your help!

Stuart McCall said:
<snip>

Ok let's start afresh. Here's how I'd write this:

Private Sub Command69_Click()
With Me.gNotes
.Locked = False
.Value = .Value & vbCrLf & Date() & "--" & Environ("Username") & "--"
.SetFocus
.SelStart = Len(Me.gNotes.Text)
End With
End Sub

Notice I'm adding to the end of the existing data, using .Value = .Value &
vbCrLf & ...
 
L

Linq Adams via AccessMonster.com

You need to check the spelling, as JD has suggested, because your other
refences to it will bomb as well, if the name is wrong. But you can actually
remove the line. Even when a textbox in a form is Locked, you can write data
to it via code.
 

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