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

After "DoCmd" 1

Status
Not open for further replies.

Hayou

Programmer
Apr 22, 2003
7
0
0
US
Okay here is my question.
1. I'm window 98 SE.
2. I useing Office 2000 (Access)
My problem is when I write this command I get a run time error
DoCmd.OpenTable "Name of table", acNormal
The debugger comes back to this line. I have taken out the ""s and put in []. I have done it with () and with nothing at all. Nothing works, I have checked the spelling. I have other DoCmd later in the code so I think it will stop there too.
 
DoCmd.OpenTable "Name of table", acViewNormal


HTH


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
I have no idea what you ment? You wrote the same thing I wrote and it doesnt work!
 
Look closely...

Look at yours:
DoCmd.OpenTable "Name of table", acNormal


Look at mine:
DoCmd.OpenTable "Name of table", acViewNormal





"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
somewhat un-related to the above but.....

i have a function which uses the following

DoCmd.OpenReport "Laboratory Data: Pre-Study", acNormal, "", "[Patient Number]=[Forms]![Laboratory Data Pre-Study: Enter Patient Number To Print]![Combo8]"

what i need to do after this part executes is set the value of a control in the table underlying the form "Laboratory Data: Pre-Study" to be True. The control is called "Report_Printed" and is on the table of the same name as the form just cited. i do not have that control appear on the form however, although, if it meant not getting to my goal, i would add it.

i'm a newbie to vba, so does this require a DoCmd ? if so, what'd it look like?
 
No that does not require the DoCmd. You can set the controls value to true with this code:

Report_Printed.Value = True

As far as it being present on the form, what you may want to do is put it on the form and set the visible property to false. You can set that in the properties box under format or you can code it with this code on the form_load event:

Report_Printed.Visible = False


If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
hi docmeizie!

sounds way tooooo ez.....

did you notice my DoCmd,

DoCmd.OpenReport "Laboratory Data: Pre-Study", acNormal, "", "[Patient Number]=[Forms]![Laboratory Data Pre-Study: Enter Patient Number To Print]![Combo8]"

does is contain a 'filter' to print the record having "Patient Number" equal to the value the user enters on for "Laboratory Data Pre-Study: Enter Patient Number To Print" control I call "Combo8"?

If so, how would the code know which record to set "Report_Printed.Value = True" on. Isn't it necessary to isolate the record much as is done in the DoCmd above?

 
Pretty much that easy.

The only thing with the Report_Printed.Value = True, you may want to put in an IF..Then Conditional so it may recognize if the report has been printed then it will set the property to true.

One question I do have for you.... is this: [Laboratory Data Pre-Study: Enter Patient Number To Print], the name of a subform? If not what is it? The naming convention is unfamiliar and hard to distinquish.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
hi!!

"One question I do have for you.... is this: [Laboratory Data Pre-Study: Enter Patient Number To Print], the name of a subform? If not what is it? The naming convention is unfamiliar and hard to distinquish."

Okay, I'll try and flesh it out...

I am using a Switchboard Manager and when the user gets to the Main screen, he can opt to print out any of the forms he's completed. He clicks on "Print Forms" and is then presented with the names of the forms he can print. Clicking on any one of them behind the scenes opens a form. The form typically has one (and sometimes two controls) as well as a pair of command buttons. One control which is always on this kind of form accepts the "Patient Number" (this is Combo8), the other control if it appears on this kind of form accepts a 'Visit Number' -- since some forms can get repeatedly completed over many visits to a clinic it's necessary to specify which visit you're interested in. Hopefully, this is still clear. The Print command button is linked with a macro that basically actuates the Print Report or is it Open Report command and prints a 'report' which is actually just a hard copy version of the data entry form. The Close button does what you'd think it does. When the form is printed, it's kind of assumed that the data have all been entered on it and won't be modified but......

I want to enhance this simple scenario a bit, because I thought about the question of what would happen were a report printed and then the data modified. How would you know.

So I came up with this 'idea'. Undoubdtedly there're many ways to tackle it, but the one I'm favoring would mean the following.

I'd add a field, "Report_Printed" to the table underlying the form. It'd be Yes/No.

I'd convert the macro that prints the report to a function and embellish it. I'd have the resulting function set the value of the Report_Printed field in the table for the patient designated by the DoCmd code up there set to 'True'.

I'd also code some function that would be attached to the form (on opening perhaps) such that the next time the user went to edit a record, it would test to see if the value of the 'Report_Printed' field were TRUE. If it were, then the function would issue a message to the user reminding the user that a report had already been generated for the patient and that upon completing the data entry/editing for this patient that another report would need to be generated.

The Report_Printed field would have a default value of 'False' and would remain 'True' once the first report got generated. So if the user went into the same patient's record a third, or fourth, etc. etc. time, he'd be reminded to re-print the report IF there were any changes to the data
 
Okay here we go:

Now to check to see if the record has been printed already:

If there is a button that you press to print, you are going to want to put this code there in the OnClick event.
Basically what this is going to do is right before print is actually executed, it checks to see if the record has already been printed. If the report has already been printed then a message box will appear and say "This report has already been printed, if you have made changes to this record/report click OK to print a new report." User clicks OK to Print and Cancel to stop the whole Print action. Here is the code for that:

dim RetValue

If Report_Printed.Value = Yes Then 'Or -1
If msgbox("This report has already been printed, if you have made changes to this record click OK to print a new report.", vbOkCancel, "Do You Want To Continue?")= vbOk Then
*Print Report Code*
Report_Printed.Value = True 'True will be -1 if it is a yes/no datatype...
Else If msgbox("This report has already been printed, if you have made changes to this record click OK to print a new report.", vbOkCancel, "Do You Want To Continue?")= vbCancel Then
Exit Sub
End If
else
*Print Report Code*
Report_Printed.Value = True 'True will be -1 if it is a yes/no datatype...
End If

I know this looks like a lot of mumbo-jumbo at first glance but trust me it should work depending on a couple of conditions: 1. Make sure the Report_Printed datatype in the table is set to yes/no 2. Where it say *Print Report Code* that means the code that you can get from the command button wizard or your own print code. Let me know how this pans out. Good Luck.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
thanks! really useful stuff. don't know that i can use it just now as the spec'ns are changing (again!) but i just might later on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top