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

using command buttons on forms

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
i've picked one form, called 'Registration' as a sort of test bed on which to develop the functionality which will hopefully be applied to the others. by way of laying the groundwork for the rest of this query, 'Registration' uses a Record Source of the same name. the variable 'Form_Flag'is a Y/N variable i've added to the underlying 'Registration' table.

i currently have a collection of forms with 'Print' buttons, each button launching a report that prints out the contents of the data entry screen for the patient record being viewed.

i think it'd be 1) good to remind the user as they scroll through records via a form which records have been printed and which have not, 2) that later i might provide the users with the ability to create a query as well -- its purpose being to filter out those records that had never been printed or possibly vice versa.

in terms of how i'd try to implement goal '1', what i'm trying to do is cause the 'Print' button to disappear when a record gets printed, disallow further editing of this form for this record and finally to display a previously invisible 'Enable Edits' button on the form (its purpose being to unlock the form for this patient's record and to visually remind a user that there exists a printed record of the form for this patient).

wrt when the 'Enable Edits' button is visible, the record would become editable again once 'Enable Edits' got clicked, at which time the 'Enable Edits' button would disappear and the 'Print' button would re-appear.

hopefully that covers the lot.

this is what i've come up with so far.

Private Sub Form_Current()
If Me!Form_Flag = True Then
Me.AllowEdits = False
Me.EnableEditsBtn.Visible = False
Else
Me.AllowEdits = True
Me.EnableEditsBtn.Visible = False
End If
End Sub

in addition to the code above, i've got the following for the OnClick of the 'Print' report button:

Private Sub Command238_Click()
On Error GoTo Err_Command238_Click

Dim stDocName As String

Me!Form_Flag = True
Me.Refresh
Me.AllowEdits = False
DoCmd.GoToControl Me.EnableEditsBtn
Me.EnableEditsBtn.Visible = True
Me.Command238.Visible = False

stDocName = "Registration"

Me.Refresh

OpenReport_FX stDocName, acNormal, "", "[Patient Number] = " & Me![Patient Number]

Exit_Command238_Click:
Exit Sub

Err_Command238_Click:
MsgBox Err.description
Resume Exit_Command238_Click

End Sub

and the following for the OnClick event of the 'Enable Edits' button:

Private Sub EnableEditsBtn_Click()
Me.AllowEdits = True
Me.Command238.Visible = True
DoCmd.GoToControl Me.EnableEditsBtn
Me.EnableEditsBtn.Visible = False
End Sub

there's more work that needs doing though....for example, when i click on the 'Print' button, i get a message to the effect "An expression you entered is the wrong data type for one of the arguments". the 'Print' button does not disappear and the 'Enable Edits' button does not wondrously appear either.


“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 

Hello Uscitizen,

First question is why?
Try this, select filter, it will allow user to select a specific set of records in a field on your form, and print those out.

For example:
a,b,b,b,c,c,c,d,d,a,a,a,b,b

use select filter on field and choose a. It will show only a.

It is a lot less complicated, and also gives the user the change to make a mistake and print something again, and again, and again...

P.s. like your quote.

"As knowledge increases frustation/anger decreases"
Nitsche



 
hi, i guess the question wasn't posed as i thought it was. but i have managed to figure out the answer on my own. thanks, though.

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
uscitizen,

I don't have an answer to #2, but for #1,

I'd have a checkbox on the form that denotes whether the current record has been printed or not, default to no for new records. When the print report button is clicked, make it check the checkbox to yes, and then disable all the text boxes on the form for the current record. You could make it shift focus to the checkbox and then make the print report button disabled and invisible, if you want, but you must do it in that order. I think you could even render the checkbox invisible, if you don't want it to show on the form. If later editing is necessary, then the edit button should be left disabled and invisible by default, but made visible and enabled by the on click action of the print report button. When you click the now visible edit record button on an already printed record, whose controls are now not enabled, the on click action enables all your text boxes, and the print report button is enabled and visible again.

How does that sound? I'm doing something a little similar on a testing form, where the test subject is given a report on their test, and signs off electronically. I click a button, and the sign in form appears, and they sign off on receipt of test results. The on click event also checks my box to denote the person recieved results of testing, and enables a DateNotified text box. Works pretty good.

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top