Modify records

  • Thread starter Thread starter Bernd
  • Start date Start date
B

Bernd

I would like, that, selected a patient, just in the list
(within a combobox), and clicking on a "modify" button,
all the underlying fields (of the form) are automaticly
compiled with the data of the selected patient (record),
so that I have only to change a few fields and not all
the fields, and at the end I click on the "save" button
and I am going to save the modified data, overwriting the
prevent record.
Is it possibly and how?
Thanks
Bernd
 
Hi,
If you use the wizard to create you combo, the code will be written for you.
Just make sure you have a bound form and choose the "find a record
based on my selection" when running the wizard. Access will do everything for you,
including the saving of data.
 
Hi, does this works also with option groups or only with
textboxes. I mean that when I select a patient from the
combobox I would like that the corripondent option
selected before, for that patient, are compiled in the
option group.
For instance, if I have a patient "X" and a set of option
related by him, like age, selected from a option group
between various options, when I want to modify the
options of patient "X", I select it from my combobox and
I would like that in the "age option group" is selected
the age I've compiled before, so that I can change it and
select another option.
I hope you'lle understand what I try to explain.
Thanks
Bernd
-----Original Message-----
Hi,
If you use the wizard to create you combo, the code will be written for you.
Just make sure you have a bound form and choose the "find a record
based on my selection" when running the wizard. Access will do everything for you,
including the saving of data.

--
HTH
Dan Artuso, Access MVP


"Bernd" <[email protected]> wrote in
message news:[email protected]...
 
Hi,
It works with all bound controls. If you have an unbound control then
you have to populate it yourself.
I suggest trying it out and then ask more questions when you see how it works.
 
I tried it, but when I select a patient in the combobox,
the option in option group don't change automaticly to
the right option associated to the selected patient. At
other part, if I insert a textbox, in place of the option
group, and I select a patient, in the textbox there
compares the associated value.
How can I achive this problem? Do I, maybe,have to change
the data type of the field associated to the option
group? Now it is "text".
Thanks
Bernd
 
Hi,
You would have to put some code in the Current event of the form
to select the correct option. You could use DLookup to get the value
from your table and then use that to select the correct option.

I can't give you exact code without more details. How do you enter the option now?
You must have a form to do this?
 
Hi,
I exactly have a form, associated to a table
(Paziente),with a combobox (a list of patients), which
takes its values from Paziente (the keyfield of table
Paziente), than I've a series of "option groups" under
the combobox, each one associated to a field of
table "Paziente". For instance "Age" is one of these
option groups which has 4 options (<25 age; from 26 to 35
age; from 36 to 45 age; > 46 age), then I select one of
the options filling up the near box. Further I have a
Save button which saves the compiled information in the
table Paziente. I have a "Modify" button too, that when I
select a Patient from my combobox, on clicking have to
make that all the underlying options groups are filled up
with the option related on the selected patient.
What kind of code do I have to write, and where, to
obtain the upper described situation?
Thanks
Bernd
-----Original Message-----
Hi,
You would have to put some code in the Current event of the form
to select the correct option. You could use DLookup to get the value
from your table and then use that to select the correct option.

I can't give you exact code without more details. How do you enter the option now?
You must have a form to do this?

--
HTH
Dan Artuso, Access MVP


"Bernd" <[email protected]> wrote in
message news:[email protected]...
 
Hi,
How are the options stored in your table?
What are the option values on your form?
Option buttons cannot have string values, so I'm wondering, how do you
get the values into your table in the first place?

The code you would need would go in the Current event of your form.
If I understand correctly (please tell me if this is not right), you have strings stored in
your table such as "< 25", "from 26 to 35" and so on.

So, you have to use DLookup() to pull the value for the current record.
Something like:

Dim strValue as String

strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select

You have to substitute the correct names of course and add the rest
of the Case statements, but it will be something along those lines
 
The options in my form are something like the following:

<25 O
26<x>35 O
......

The O near the options are the box to fill up.
When I created the option groups the wizard asked me to
associate a value to each of the options so in my my
table < 25 is equivalent to 1 , 26<x>35 is equivalent to
2, etc. So if I fill up the box near <25 in my table in
the field age there will be the value 1.
Thanks
-----Original Message-----
Hi,
How are the options stored in your table?
What are the option values on your form?
Option buttons cannot have string values, so I'm wondering, how do you
get the values into your table in the first place?

The code you would need would go in the Current event of your form.
If I understand correctly (please tell me if this is not
right), you have strings stored in
your table such as "< 25", "from 26 to 35" and so on.

So, you have to use DLookup() to pull the value for the current record.
Something like:

Dim strValue as String

strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select

You have to substitute the correct names of course and add the rest
of the Case statements, but it will be something along those lines

--
HTH
Dan Artuso, Access MVP


Hi,
I exactly have a form, associated to a table
(Paziente),with a combobox (a list of patients), which
takes its values from Paziente (the keyfield of table
Paziente), than I've a series of "option groups" under
the combobox, each one associated to a field of
table "Paziente". For instance "Age" is one of these
option groups which has 4 options (<25 age; from 26 to 35
age; from 36 to 45 age; > 46 age), then I select one of
the options filling up the near box. Further I have a
Save button which saves the compiled information in the
table Paziente. I have a "Modify" button too, that when I
select a Patient from my combobox, on clicking have to
make that all the underlying options groups are filled up
with the option related on the selected patient.
What kind of code do I have to write, and where, to
obtain the upper described situation?
Thanks
Bernd of
the form correct
option. do
you enter the option now?
message news:[email protected]... from
the in
the change
it in
the


.
 
Hi,
Okay, so the code you need would be similiar to what I provided.
It goes in the Current event of your form.

I have no idea of your level of coding but give it a try and ask about
what you don't understand.

--
HTH
Dan Artuso, Access MVP


Bernd said:
The options in my form are something like the following:

<25 O
26<x>35 O
.....

The O near the options are the box to fill up.
When I created the option groups the wizard asked me to
associate a value to each of the options so in my my
table < 25 is equivalent to 1 , 26<x>35 is equivalent to
2, etc. So if I fill up the box near <25 in my table in
the field age there will be the value 1.
Thanks
-----Original Message-----
Hi,
How are the options stored in your table?
What are the option values on your form?
Option buttons cannot have string values, so I'm wondering, how do you
get the values into your table in the first place?

The code you would need would go in the Current event of your form.
If I understand correctly (please tell me if this is not
right), you have strings stored in
your table such as "< 25", "from 26 to 35" and so on.

So, you have to use DLookup() to pull the value for the current record.
Something like:

Dim strValue as String

strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select

You have to substitute the correct names of course and add the rest
of the Case statements, but it will be something along those lines

--
HTH
Dan Artuso, Access MVP


Hi,
I exactly have a form, associated to a table
(Paziente),with a combobox (a list of patients), which
takes its values from Paziente (the keyfield of table
Paziente), than I've a series of "option groups" under
the combobox, each one associated to a field of
table "Paziente". For instance "Age" is one of these
option groups which has 4 options (<25 age; from 26 to 35
age; from 36 to 45 age; > 46 age), then I select one of
the options filling up the near box. Further I have a
Save button which saves the compiled information in the
table Paziente. I have a "Modify" button too, that when I
select a Patient from my combobox, on clicking have to
make that all the underlying options groups are filled up
with the option related on the selected patient.
What kind of code do I have to write, and where, to
obtain the upper described situation?
Thanks
Bernd
-----Original Message-----
Hi,
You would have to put some code in the Current event of
the form
to select the correct option. You could use DLookup to
get the value
from your table and then use that to select the correct
option.

I can't give you exact code without more details. How do
you enter the option now?
You must have a form to do this?

--
HTH
Dan Artuso, Access MVP


message I tried it, but when I select a patient in the
combobox,
the option in option group don't change automaticly to
the right option associated to the selected patient. At
other part, if I insert a textbox, in place of the
option
group, and I select a patient, in the textbox there
compares the associated value.
How can I achive this problem? Do I, maybe,have to
change
the data type of the field associated to the option
group? Now it is "text".
Thanks
Bernd

-----Original Message-----
Hi,
It works with all bound controls. If you have an
unbound
control then
you have to populate it yourself.
I suggest trying it out and then ask more questions
when
you see how it works.

--
HTH
Dan Artuso, Access MVP


Hi, does this works also with option groups or only
with
textboxes. I mean that when I select a patient from
the
combobox I would like that the corripondent option
selected before, for that patient, are compiled in
the
option group.
For instance, if I have a patient "X" and a set of
option
related by him, like age, selected from a option
group
between various options, when I want to modify the
options of patient "X", I select it from my combobox
and
I would like that in the "age option group" is
selected
the age I've compiled before, so that I can change
it
and
select another option.
I hope you'lle understand what I try to explain.
Thanks
Bernd
-----Original Message-----
Hi,
If you use the wizard to create you combo, the code
will
be written for you.
Just make sure you have a bound form and choose
the "find a record
based on my selection" when running the wizard.
Access
will do everything for you,
including the saving of data.

--
HTH
Dan Artuso, Access MVP


"Bernd" <[email protected]>
wrote in
message [email protected]...
I would like, that, selected a patient, just in
the
list
(within a combobox), and clicking on a "modify"
button,
all the underlying fields (of the form) are
automaticly
compiled with the data of the selected patient
(record),
so that I have only to change a few fields and
not
all
the fields, and at the end I click on the "save"
button
and I am going to save the modified data,
overwriting
the
prevent record.
Is it possibly and how?
Thanks
Bernd



.



.



.


.
 
Hi,
I tried to insert the code that you've proposed me, but
it doesn't work. I think I do something wrong.
If I understand well in the main instruction you've wrote:
strValue = DLookup("[age]","Paziente",patientId = " &
Me.txtPatientId)
Age= name of my option group
Paziente= name of my table
PazienteId= name of the field of the combobox
txtPatientId= ???
I wrote the name of the option group instead of
txtPatientId but I don't it is well, isn't it?
When I run my form there appears the following error
message:
Syntax error (missing operator)in query
expression 'Paziente= '
What's wrong??
Thanks Bernd
-----Original Message-----
Hi,
How are the options stored in your table?
What are the option values on your form?
Option buttons cannot have string values, so I'm wondering, how do you
get the values into your table in the first place?

The code you would need would go in the Current event of your form.
If I understand correctly (please tell me if this is not
right), you have strings stored in
your table such as "< 25", "from 26 to 35" and so on.

So, you have to use DLookup() to pull the value for the current record.
Something like:

Dim strValue as String

strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select

You have to substitute the correct names of course and add the rest
of the Case statements, but it will be something along those lines

--
HTH
Dan Artuso, Access MVP


Hi,
I exactly have a form, associated to a table
(Paziente),with a combobox (a list of patients), which
takes its values from Paziente (the keyfield of table
Paziente), than I've a series of "option groups" under
the combobox, each one associated to a field of
table "Paziente". For instance "Age" is one of these
option groups which has 4 options (<25 age; from 26 to 35
age; from 36 to 45 age; > 46 age), then I select one of
the options filling up the near box. Further I have a
Save button which saves the compiled information in the
table Paziente. I have a "Modify" button too, that when I
select a Patient from my combobox, on clicking have to
make that all the underlying options groups are filled up
with the option related on the selected patient.
What kind of code do I have to write, and where, to
obtain the upper described situation?
Thanks
Bernd of
the form correct
option. do
you enter the option now?
message news:[email protected]... from
the in
the change
it in
the


.
 
Hi,
Look in help for a full explanation of DLookup().
Basically:
Age: this is the field in Paziente where you have stored the age group value.
patientId : this the field in the table that identifies the patient
txtPatientId: this is the field in your form's recordset that is the current patientid

The rest you have correct.

So the basic steps are:

Get the option value from your table for the current patient:
strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Set the option group to that value:
Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select


--
HTH
Dan Artuso, Access MVP


Bernd said:
Hi,
I tried to insert the code that you've proposed me, but
it doesn't work. I think I do something wrong.
If I understand well in the main instruction you've wrote:
strValue = DLookup("[age]","Paziente",patientId = " &
Me.txtPatientId)
Age= name of my option group
Paziente= name of my table
PazienteId= name of the field of the combobox
txtPatientId= ???
I wrote the name of the option group instead of
txtPatientId but I don't it is well, isn't it?
When I run my form there appears the following error
message:
Syntax error (missing operator)in query
expression 'Paziente= '
What's wrong??
Thanks Bernd
-----Original Message-----
Hi,
How are the options stored in your table?
What are the option values on your form?
Option buttons cannot have string values, so I'm wondering, how do you
get the values into your table in the first place?

The code you would need would go in the Current event of your form.
If I understand correctly (please tell me if this is not
right), you have strings stored in
your table such as "< 25", "from 26 to 35" and so on.

So, you have to use DLookup() to pull the value for the current record.
Something like:

Dim strValue as String

strValue = DLookup("[age]","Paziente",patientId = " & Me.txtPatientId)

Select Case strValue
Case "< 25"
Me.yourOptionGroup = 1
Case etc
End Select

You have to substitute the correct names of course and add the rest
of the Case statements, but it will be something along those lines

--
HTH
Dan Artuso, Access MVP


Hi,
I exactly have a form, associated to a table
(Paziente),with a combobox (a list of patients), which
takes its values from Paziente (the keyfield of table
Paziente), than I've a series of "option groups" under
the combobox, each one associated to a field of
table "Paziente". For instance "Age" is one of these
option groups which has 4 options (<25 age; from 26 to 35
age; from 36 to 45 age; > 46 age), then I select one of
the options filling up the near box. Further I have a
Save button which saves the compiled information in the
table Paziente. I have a "Modify" button too, that when I
select a Patient from my combobox, on clicking have to
make that all the underlying options groups are filled up
with the option related on the selected patient.
What kind of code do I have to write, and where, to
obtain the upper described situation?
Thanks
Bernd
-----Original Message-----
Hi,
You would have to put some code in the Current event of
the form
to select the correct option. You could use DLookup to
get the value
from your table and then use that to select the correct
option.

I can't give you exact code without more details. How do
you enter the option now?
You must have a form to do this?

--
HTH
Dan Artuso, Access MVP


message I tried it, but when I select a patient in the
combobox,
the option in option group don't change automaticly to
the right option associated to the selected patient. At
other part, if I insert a textbox, in place of the
option
group, and I select a patient, in the textbox there
compares the associated value.
How can I achive this problem? Do I, maybe,have to
change
the data type of the field associated to the option
group? Now it is "text".
Thanks
Bernd

-----Original Message-----
Hi,
It works with all bound controls. If you have an
unbound
control then
you have to populate it yourself.
I suggest trying it out and then ask more questions
when
you see how it works.

--
HTH
Dan Artuso, Access MVP


Hi, does this works also with option groups or only
with
textboxes. I mean that when I select a patient from
the
combobox I would like that the corripondent option
selected before, for that patient, are compiled in
the
option group.
For instance, if I have a patient "X" and a set of
option
related by him, like age, selected from a option
group
between various options, when I want to modify the
options of patient "X", I select it from my combobox
and
I would like that in the "age option group" is
selected
the age I've compiled before, so that I can change
it
and
select another option.
I hope you'lle understand what I try to explain.
Thanks
Bernd
-----Original Message-----
Hi,
If you use the wizard to create you combo, the code
will
be written for you.
Just make sure you have a bound form and choose
the "find a record
based on my selection" when running the wizard.
Access
will do everything for you,
including the saving of data.

--
HTH
Dan Artuso, Access MVP


"Bernd" <[email protected]>
wrote in
message [email protected]...
I would like, that, selected a patient, just in
the
list
(within a combobox), and clicking on a "modify"
button,
all the underlying fields (of the form) are
automaticly
compiled with the data of the selected patient
(record),
so that I have only to change a few fields and
not
all
the fields, and at the end I click on the "save"
button
and I am going to save the modified data,
overwriting
the
prevent record.
Is it possibly and how?
Thanks
Bernd



.



.



.


.
 
Back
Top