Running code on individual records

bsnalex

Registered User.
Local time
Today, 11:34
Joined
Feb 27, 2009
Messages
27
So in my database i'm creating a live form that will open up a list of patients and when they are seen. one of the bits is a button that before they arrive says "Not Arrived" and after they arrive it says "Arrived". The code works fine:

Code:
Private Sub Command68_Click()
Dim C1 As String
Dim C2 As String

C1 = "Not Arrived"
C2 = "ARRIVED"

With Me.Command68
If .Caption = C1 Then
    .Caption = C2
ElseIf .Caption = C2 Then
    .Caption = C1
End If
End With
End Sub

The problem is after clicking the button on any of the records, it changes the text on all records, to wit:

Edit: I tried to attach images or links to images, but my post-count is too low. The before-click screenshot is /3QnBkgG on imgur. The after-click screenshot is 9VZWzzp on the same site.

Bear in mind I've only clicked the button (it's white, so it doesn't look like a button) on the top record.

The form is set to continuous forms, not sure if that has anything to do with it.

Anyone know how I can get the code to run on individual records, rather than applying the first-record's results across all records?

Thanking in advance.
 
As far as I'm aware, you cannot with a command button.

I would recommend using a toggle button instead. (Question: what about other patient statuses, such as "In Exam Room", "Seen", etc?)
 
I cannot access http://www.imgur/3QnBkgG ???

You appear to be changing the caption of the button, which will be repeated for each record. You would need an individual field on the record. I don't think you can refer to an individual control in a row on a continuous form?
 
Question: what about other patient statuses, such as "In Exam Room", "Seen", etc?

It's to use in a multidisciplinary clinic-- the smudged out headings at the top of the form are the clinician's names. The boxes are merely going to show the time on the clock that the notes were passed to that clinician, and not their status of seen, in room, etc.

I'll try toggle button
 
I have a high-enough post-count now-

Before click:
3QnBkgG.jpg


After click:
9VZWzzp.jpg
 
as gasman said: you only have one instance of each control, not one for each record. T o make soemthing look different, you need to bind the control to a column in the record source. If bound, a toggle should work
 
I have changed it to a toggle button, but again, if i click the button in the first record, it changes for all records. All I want is to change things in the active record. Filling in the boxes isn't a problem, as they are part of the datasheet, but its the formatting of the individual records on the form that seems to be the issue.
 
I have changed it to a toggle button, but again, if i click the button in the first record, it changes for all records. All I want is to change things in the active record. Filling in the boxes isn't a problem, as they are part of the datasheet, but its the formatting of the individual records on the form that seems to be the issue.

The key is the item has to be bound to a record.
Perhaps consider a drop down on the record?
 
as gasman said: you only have one instance of each control, not one for each record. T o make soemthing look different, you need to bind the control to a column in the record source. If bound, a toggle should work

Yknow what, I'm just gonna do it the easy way. New field in the table that's a combo box, "arrived", "not arrived", "non-attender".
 
If you are going to foist this thing upon a secretary, then design it such that it is executable without using the mouse but tabs and keys only. Here a toggle (reachable by tabbing) wins over a combo, where the options require opening the list (and few remember the shortcut ALT down arrow for that)
 
If you are going to foist this thing upon a secretary, then design it such that it is executable without using the mouse but tabs and keys only. Here a toggle (reachable by tabbing) wins over a combo, where the options require opening the list (and few remember the shortcut ALT down arrow for that)
Nah it's going to be used by a few different people, and some of them are not tab-savvy, unfortunately.

Now, onto the next problem. The combo box works, and I want to have the fields turn optic-yellow when their status is set to "Arrived". The code is such that:
Code:
Private Sub ATCST_AfterUpdate()

Dim OPYel As Long

OPYel = RGB(231, 244, 66)

If Me.ATCST = "Arrived" Then
    Me.RGBCHID.BackColor = OPYel
    Me.PatName.BackColor = OPYel
    Me.TCDESC.BackColor = OPYel
    Me.VISPURP.BackColor = OPYel
    Me.ATCMNT.BackColor = OPYel
    Me.ATCST.BackColor = OPYel
    Me.ATTIME.BackColor = OPYel
End If
End Sub

does in fact turn the fields optic yellow, but again, it does it on every record, instead of just the record I am working on at the moment. If anyone can offer help on this, I'd greatly appreciate it.

And yes I only included the "arrived" clause on the If statement. I'm just working on that one at the moment, I'll add the not arrived and not attended clauses later.
 
If you are going to foist this thing upon a secretary, then design it such that it is executable without using the mouse but tabs and keys only. Here a toggle (reachable by tabbing) wins over a combo, where the options require opening the list (and few remember the shortcut ALT down arrow for that)

To that end, if each option began with a different letter, then it would only be one key press?

Perhaps something like

"To Attend";"Attended";"Not Attended"
 
That's no problem, my chocies are "Not Arrived";"Arrived";"WNB"

Not arrived is default value. WNB stands for Was Not Brought (it's a children's hospital so we call it was not brought rather than did not attend...we're caring like that)
 

Users who are viewing this thread

Back
Top Bottom