Need help with access option group

jianpppp

New member
Local time
Today, 12:15
Joined
Feb 21, 2013
Messages
4
I am new to access and i am trying for few days to get this work for my assignment. So i have a option group, which consists of 4 options. If i toggle option 1 the value in an unbound textbox would be 50, if option 2 it will be 50, if option 3 it will be 100 and if i toggle option 4 its value is 0. I cant seem to get it to work, heres my code in vba. Extratotal is an unbound textbox, the opt1 to opt4 is the name of the option buttons. Their option values are 1-4. How can i get this to work? Help is greatly appreciated.

Private Sub Frame72_AfterUpdate()
Select Case Frame72.Value
Case 1
Me.opt1.Value = 1
Me.extratotal.Value = "50"
Case 2
Me.opt2.Value = 2
Me.extratotal.Value = "50"
Case 3
Me.opt3.Value = 3
Me.extratotal.Value = "100"
Case 4
Me.opt4.Value = 4
Me.extratotal.Value = "0"
End Select

End Sub
 
Hello janpppp, Welcome to AWF.. :)

I am a bit confused, of why you set the value of the Optionboxes? :confused: Also what is not working? I can see your code works as you have asked it to work.. I am not sure..

Anyway, Try this instead..
Code:
Private Sub Frame72_AfterUpdate()
    Select Case Me.Frame72
        Case 1, 2
            Me.extratotal = "50"
        Case 3
            Me.extratotal = "100"
        Case 4
            Me.extratotal = "0"
    End Select
End Sub
 
Hello janpppp, Welcome to AWF.. :)

I am a bit confused, of why you set the value of the Optionboxes? :confused: Also what is not working? I can see your code works as you have asked it to work.. I am not sure..

Anyway, Try this instead..
Code:
Private Sub Frame72_AfterUpdate()
    Select Case Me.Frame72
        Case 1, 2
            Me.extratotal = "50"
        Case 3
            Me.extratotal = "100"
        Case 4
            Me.extratotal = "0"
    End Select
End Sub

worked like a charm!!!! thank you, the values were set automatically when i was configuring it in the control wizard. Uhmm also, what should i do in order to make an unbound textbox update? My default value of it is "=[Insurance]+[Price]*0.03*[Duration]+[extratotal]" but i have to click on it for it to update the price. Most of the calculated value in my form doesnt update.. i have to like refresh the form for it to update..
 
Last edited:
In the OnChange event of the following fields:

[Insurance]
[Price]
[Duration]
[extratotal]

Private Sub YourTextBox_Change()
Forms!YourFormName.Requery
End Sub
 
In the OnChange event of the following fields:

[Insurance]
[Price]
[Duration]
[extratotal]

Private Sub YourTextBox_Change()
Forms!YourFormName.Requery
End Sub
That doesnt work.. The unbound textbox value does not change.. Am i supposed to do it for all the 4 column somthing like
Private Sub Insurance_Change()
Forms!loandetailsform.Requery
EndSub

Also I use this code to refresh the Duration textbox value every time i change the value of the Dates, but it does not seem to be working? What should i do..
Private Sub DateOut_Change()
Duration = DateDiff("d", [DateOut], [DateReturn])

End Sub

Private Sub DateReturn_Change()
Duration = DateDiff("d", [DateOut], [DateReturn])

End Sub

Edit: i changed change() to afterupdate() and it works now. thanks guys repped!

Uhmm but theres another problem now, i need the option group value to stay as it is and how do i go about doing that? Like i opted for Option 3 and i have default value of Option 1 and i do not want the value to go back to its default after i refresh the form.

Also when i go next record , the Duration and Totalprice column does not update!!! Please have a look at my database and tell me what is wrong
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom