tranfer data from command button to table

G

Guest

I created 2 command buttons at the bottom of my forms view. One button is
called "Surgery" the other is "No Surgery". I want the doctors to click on
"No Surgery" and the word "No surgery" will be updated in the patient's
record in the tables. Can this be done?

I know it starts with going to "On click" in the properties view, but I
don't know how to link it to the specific patient in the table view.

Thanks,
Rookie!
 
B

benyod79 via AccessMonster.com

Rookie,

you're right with the On Click. Make it an [Event Procedure]. You can't do it
in Datasheet view though. Click the three dots and it'll take you to Visual
Basic. It'll look something like this:

Private Sub [YourFieldName]_OnClick()

Me.[YourFieldName].Value = "No Surgery"

End Sub

Hope this helps.
 
S

Steve Schapel

Rookie,

There is a problem with this approach. Which is that the next time you
go to that patient's record, you won't be able to see which button was
clicked (or indeed if either has been). Well, that is, unless you have
the surgery/no surgery field dispolayed on the form... and then if you
have that, there's no point in using command buttons to enter it, as it
would be just as easy entering it directly on the form using a combobox
or something, know what I mean?

There is a nice way you can do this though. First of all, make the
field in the table that the surgery/no surgery relates to into a Number
data type. So 'Surgery' will be entered into the table "behind the
scenes" as 1, and 'No Surgery' will be entered as 2. Don't worry - when
it comes to the point of needing to display this data for the users, it
is easy to get it to actually show up as the human-readable "Surgery"
and "No Surgery".

Then, on your form, put an Option Group which is bound to this field in
your table. And then add two Toggle Buttons to the Option Group. Make
the lables on the toggle buttons to read 'Surgery' and 'No Surgery'.
Now you've got something that looks pretty much like the 2 command
buttons you originally had.

So now, the doctor can click 'Surgery' or 'No surgery'. You don't need
to use a macro or code to do anything. Which button was clicked will be
clearly visible because the button will be of a 'sunken' style. And
this will be shown for each patient the next time the form is opened at
their record.

Of course, there will be a bit of a learning curve for you in making
this happen. But it is actually not difficult, and will be worth the
effort.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top