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
Microsoft MVP
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200810/1
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)
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?
--
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?
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
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
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.
"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
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
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).
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.
>
--