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

Option groups - timing of value update to field

Status
Not open for further replies.

dduffy

Technical User
Jul 30, 2002
20
IE
I currently have an option group with 2 choices values update the field on the underlying table with 1 or 2.

I have setup a query to calculate the value of all records populated with 1. I want this query to run each time an option has been chosen. I have the requery working fine but the problem is that the table does not get updated until the control has been exited.

I have used the option group wizard for this function and I cannot see where the code is.

How can I get the table to update as soon as option 1 has been chosen rather than when I move on to the next record?

lylt
BBB
 
Try This for Access 2000

Field in table is called Field1
Option group on form, option1 and option2

Option Compare Database

Private Sub Option1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Field1 = 1
Call SaveRec
End Sub

Private Sub Option2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Field1 = 2
Call SaveRec
End Sub

Private Sub SaveRec()
On Error GoTo Err_SaveRec


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRec:
Exit Sub

Err_SaveRec:
MsgBox Err.Description
Resume Exit_SaveRec



Hope this helps
 
I have initialised the code but I get an error:
expression on mousedown event....error: problem occurred while MS Accesswas communicating with OLE server or ActiveX control.

* the expression may not result in use of macro or user defined function or [event procedure]
* there may have been an error in evaluating function, event, or macro

any ideas?

Cheers
 
I not sure

did you just copy and past in the code and change the appropriate object and field names?

If so you may have to generate the subroutine using the properties from the option buttons - mousedown event and then type in the code for the subroutine

the code was for access 2000. What access version are you using?

 
I went into the code builder through the mousedown event in the properties page, and them typed in the code but I have only used the field name (with no other reference to form or control or table) the group options box is bound to the field QQRNCLD.

I can understand the 1st 2 events but I don't really ubderstand the code for the SaveRec object. I have entered the following code. I have not altered the checkbox properties for their OPtion Value in the Data properties which still stand at 1 and 2 respectively.

My code is as follows.

Private Sub Check37_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
QQRNCLD = 1
Call SaveRec
End Sub

Private Sub Check39_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
QQRNCLD = 2
Call SaveRec
End Sub

Private Sub SaveRec()
On Error GoTo Err_SaveRec


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRec:
Exit Sub

Err_SaveRec:
MsgBox Err.Description
Resume Exit_SaveRec

'Thanks for you help!'
 
I generated the saverec code by putting a command button on my control and using the wizard to save the record. then I copied the code to my sub routine.
If simply uses the access menus and selects the save menu option.

I did not have my option buttons bound. maybe that is the reason.
 
cOOL i HAVE IT ALMOST WORKING NOW

oNLY PROBLEM i HAVE IS THAT WHEN i HIT THE 2ND OPTIONS BOX the 1st one stays selected the update does however, update the with the correct flag. If I leave the form it then updates the the checked box (i.e. have both options checked at this stage) to unchecked.

Any ideas.

I do appreciate your help.

Cheers

 
I have it all sorted, thanks to your help!

Thanks you VERY much Paddyo!!!

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top