Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What's wrong with this code? I keep getting an error

0 views
Skip to first unread message

Scuda

unread,
Oct 7, 2008, 12:44:01 PM10/7/08
to
Hi guys, when attempting to compile in VB, it keeps stopping here:

Private Sub cmdPrintPreview_Click()
Me.Refresh ' this forces a disk write
DoCmd.OpenReport "rptSITReliefSheet", acPreview, , "id = " & Me!id
End Sub

and giving me an error stating Compile Error: Method or Data member not
found. I have been using this command for a while with no problems. I use it
to go to the last report.

Thanks!

Chris O'C via AccessMonster.com

unread,
Oct 7, 2008, 12:55:26 PM10/7/08
to
Look in your references. Are any of them listed as missing? Fix them. If
not add a new reference, close the reference window and try to compile again.
Open the references window again and remove the extra reference you just
added. Try to compile again. Go back to the references window. Do you see
any missing references now? Fix them.

Chris
Microsoft MVP

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200810/1

Dirk Goldgar

unread,
Oct 7, 2008, 1:00:26 PM10/7/08
to
"Scuda" <Sc...@discussions.microsoft.com> wrote in message
news:EBE74B89-8799-4CA2...@microsoft.com...


Are you sure "id" is the name of a control on your form?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Scuda

unread,
Oct 7, 2008, 1:16:01 PM10/7/08
to
Thanks guys, I have no missing references, and I confirmed that is actually
on the form. When it highlites the error, it highlites the .Refresh don't
know if that helps or not.

Chris O'C via AccessMonster.com

unread,
Oct 7, 2008, 2:10:45 PM10/7/08
to
Did you use the method I suggested to find out if there were missing
references or did you look only once in the references window for "missing"
on a checked reference?

Chris
Microsoft MVP


Scuda wrote:
>Thanks guys, I have no missing references, and I confirmed that is actually
>on the form. When it highlites the error, it highlites the .Refresh don't
>know if that helps or not.
>

>> > Hi guys, when attempting to compile in VB, it keeps stopping here:
>> >

>[quoted text clipped - 9 lines]


>>
>> Are you sure "id" is the name of a control on your form?

--

Dirk Goldgar

unread,
Oct 7, 2008, 2:25:39 PM10/7/08
to
"Scuda" <Sc...@discussions.microsoft.com> wrote in message
news:AFD46C5B-16FC-426B...@microsoft.com...

> Thanks guys, I have no missing references, and I confirmed that is
> actually
> on the form. When it highlites the error, it highlites the .Refresh don't
> know if that helps or not.

That's odd. You're sure this code is on a form? Is the form bound, or is
it unbound? What version of Access are you using?

Scuda

unread,
Oct 7, 2008, 2:37:01 PM10/7/08
to
Yes, I tried exactly as you said. I am using 2003, it is a bound form.

I deleted that code (the Me.Refresh) and my function still worked so maybe
it was just the "extra" code that flagged it?

Anyhow, it compiled now, sorry for the alarm but it just (and still does)
have me puzzled a little.

thanks for the help, much appreciated.

Steph

Chris O'C via AccessMonster.com

unread,
Oct 7, 2008, 2:49:10 PM10/7/08
to
Even if you didn't need that line of code in the form's proc, it should've
compiled.

Chris
Microsoft MVP


Scuda wrote:
>Yes, I tried exactly as you said. I am using 2003, it is a bound form.
>
>I deleted that code (the Me.Refresh) and my function still worked so maybe
>it was just the "extra" code that flagged it?
>
>Anyhow, it compiled now, sorry for the alarm but it just (and still does)
>have me puzzled a little.

--
Message posted via http://www.accessmonster.com

Dirk Goldgar

unread,
Oct 7, 2008, 2:56:52 PM10/7/08
to
"Scuda" <Sc...@discussions.microsoft.com> wrote in message
news:F0E50D5F-D3BE-40D5...@microsoft.com...

> Yes, I tried exactly as you said. I am using 2003, it is a bound form.
>
> I deleted that code (the Me.Refresh) and my function still worked so maybe
> it was just the "extra" code that flagged it?
>
> Anyhow, it compiled now, sorry for the alarm but it just (and still does)
> have me puzzled a little.


I wouldn't be happy with this solution, if I were you. First, the expressed
purpose of calling Me.Refresh, according to the comment, is to force the
current record to be saved before running the report. If that's necessary,
you can't afford to leave it out -- you must use this or another method to
save the record, or else the current record's values won't appear on the
report. Personally, I prefer to use this method instead of Refresh:

If Me.Dirty Then Me.Dirty = False

You may want to consider placing that line in the code instead of the
Me.Refresh.

Second, and even more important, is that if Me.Refresh won't compile on an
Access form, something is seriously wrong. Possibly you have a broken
reference, as Chris O'C has been suggesting, or possibly your database's VB
project is corrupt. If that's the case, lots of other things are likely to
go wrong, too. I recommend you address the problem, find out what is
causing it, and fix it.

Chris O'C via AccessMonster.com

unread,
Oct 7, 2008, 3:07:32 PM10/7/08
to
I think I'd try to decompile. Make a copy of the db file and then make a
shortcut with the target in this format:

"path to msaccess.exe" "path to copy of db.mdb" /decompile

In the db copy change the startup form to (none) and rename the autoexec
macro if you have one so no startup procedures run when you first open the db.
Now close the copy of the db. Use the shortcut to open the copy of the db
and decompile it. When it's fully open go to the code editor and try to
compile the code again.

Chris
Microsoft MVP


Chris O'C wrote:
>Even if you didn't need that line of code in the form's proc, it should've
>compiled.
>
>Chris
>Microsoft MVP
>

>>Yes, I tried exactly as you said. I am using 2003, it is a bound form.
>>

>[quoted text clipped - 3 lines]


>>Anyhow, it compiled now, sorry for the alarm but it just (and still does)
>>have me puzzled a little.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200810/1

Linq Adams via AccessMonster.com

unread,
Oct 7, 2008, 5:13:20 PM10/7/08
to
In point of fact, Me.Refresh ***does not*** save a record! Refresh is used in
a multi-user environment to allow User A to see changes that User B and User
C have made to existing records! IT does not show new records that User B
and User C have added, nor does it reflect records that they have deleted!

Me.Requery

will save a record, as will

If Me.Dirty Then Me.Dirty = False

that Dirk posted. So will

DoCmd.RunCommand acCmdSaveRecord

I'm thinking maybe using Me.Refresh before the entered data has been saved
may have been responsible for your error.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Dirk Goldgar

unread,
Oct 7, 2008, 5:24:05 PM10/7/08
to
"Linq Adams via AccessMonster.com" <u28780@uwe> wrote in message
news:8b53bba28fc2b@uwe...

> In point of fact, Me.Refresh ***does not*** save a record!

Pardon, but "Me.Refresh" *will* force the record to be saved, before
returning any changes to existing records. If the goal is to force the
current record to be saved, it's a much better choice than "Me.Requery"
(which reruns the form's recordsource query), but not as good a choice as
"Me.Dirty = False" or "RunCommand acCmdSaveRecord" (both of which save the
current record without doing anything else).

Chris O'C via AccessMonster.com

unread,
Oct 7, 2008, 5:45:31 PM10/7/08
to
"In point of fact, Me.Refresh ***does not*** save a record!"

Yes, it does.

"I'm thinking maybe using Me.Refresh before the entered data has been saved
may have been responsible for your error."

She's getting a compiler error, not a data error. "Method or Data member not
found" is *always* a compiler error and has nothing to do with saving data.

Chris
Microsoft MVP


Linq Adams wrote:
>In point of fact, Me.Refresh ***does not*** save a record! Refresh is used in
>a multi-user environment to allow User A to see changes that User B and User
>C have made to existing records! IT does not show new records that User B
>and User C have added, nor does it reflect records that they have deleted!
>
>Me.Requery
>
>will save a record, as will
>
>If Me.Dirty Then Me.Dirty = False
>
>that Dirk posted. So will
>
>DoCmd.RunCommand acCmdSaveRecord
>
>I'm thinking maybe using Me.Refresh before the entered data has been saved
>may have been responsible for your error.
>

--

0 new messages