Option groups not checked

  • Thread starter Thread starter Anna
  • Start date Start date
A

Anna

Hi,

I've been trying to put string values in table fields
based on option groups on a form, and after stumbling
across some code have bodged together the following:

Private Sub ctlOption1_AfterUpdate()
Select Case Me!ctlOption1
Case 1:
FieldName= "String1"
Case 2:
FieldName= "String2"
Case 3:
FieldName= "String3"
End Select
End Sub

Now, this inputs the required string data in the table but
doesn't show up on the form (ie no boxes are checked).
Being fairly new to Access, I'm not sure how to go about
fixing this - is it possible?

Thanks,
Anna
 
Use the Current event of the form to set the unbound option group from the
value of the field:

Private Sub Form_Current()
Select Case Me![FieldName]
Case "String1"
Me.ctlOption1 = 1
Case "String2"
Me.ctlOption1 = 2
...
End Sub

If you are working in Access 2000 or later, you will also want to use the
form's Undo event to reset the group, based on the Oldvalue of the field.
 
---------- "Anna said:
I've been trying to put string values in table fields
based on option groups on a form, and after stumbling
across some code have bodged together the following:

Private Sub ctlOption1_AfterUpdate()
Select Case Me!ctlOption1
Case 1:
FieldName= "String1"
Case 2:
FieldName= "String2"
Case 3:
FieldName= "String3"
End Select
End Sub

Now, this inputs the required string data in the table but
doesn't show up on the form (ie no boxes are checked).
Being fairly new to Access, I'm not sure how to go about
fixing this - is it possible?

Anna,

please post the full exact code. For ex what is in the place of field
name, how do you handle the actual writing in the table? Is
"FieldName" also a text box on the form, is the form bound? Also, you
say "string data doesn't show up, ie no boxes are checked". From your
description I'd assume the check boxes are checked by the user, not by
code. Maybe you can give some more detail.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Thanks, that works great for existing records, but for new
ones the boxes are still unchecked. (I'm using Access 97)

Is there a way around this? I tried using onClick but that
overrode the after update code (?)

Many thanks,
Anna
-----Original Message-----
Use the Current event of the form to set the unbound option group from the
value of the field:

Private Sub Form_Current()
Select Case Me![FieldName]
Case "String1"
Me.ctlOption1 = 1
Case "String2"
Me.ctlOption1 = 2
...
End Sub

If you are working in Access 2000 or later, you will also want to use the
form's Undo event to reset the group, based on the Oldvalue of the field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I've been trying to put string values in table fields
based on option groups on a form, and after stumbling
across some code have bodged together the following:

Private Sub ctlOption1_AfterUpdate()
Select Case Me!ctlOption1
Case 1:
FieldName= "String1"
Case 2:
FieldName= "String2"
Case 3:
FieldName= "String3"
End Select
End Sub

Now, this inputs the required string data in the table but
doesn't show up on the form (ie no boxes are checked).
Being fairly new to Access, I'm not sure how to go about
fixing this - is it possible?

Thanks,
Anna


.
 
Do you have a DefaultValue for FieldName?

If not, the null option group (nothing selected) would be correct.

if you do, you could test Me.NewRecord in Form_Current, and assign the value
that matches the default.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Anna said:
Thanks, that works great for existing records, but for new
ones the boxes are still unchecked. (I'm using Access 97)

Is there a way around this? I tried using onClick but that
overrode the after update code (?)

Many thanks,
Anna
-----Original Message-----
Use the Current event of the form to set the unbound option group from the
value of the field:

Private Sub Form_Current()
Select Case Me![FieldName]
Case "String1"
Me.ctlOption1 = 1
Case "String2"
Me.ctlOption1 = 2
...
End Sub

If you are working in Access 2000 or later, you will also want to use the
form's Undo event to reset the group, based on the Oldvalue of the field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I've been trying to put string values in table fields
based on option groups on a form, and after stumbling
across some code have bodged together the following:

Private Sub ctlOption1_AfterUpdate()
Select Case Me!ctlOption1
Case 1:
FieldName= "String1"
Case 2:
FieldName= "String2"
Case 3:
FieldName= "String3"
End Select
End Sub

Now, this inputs the required string data in the table but
doesn't show up on the form (ie no boxes are checked).
Being fairly new to Access, I'm not sure how to go about
fixing this - is it possible?

Thanks,
Anna


.
 
Back
Top