|
-
Aug 16th, 2006, 10:31 AM
#1
Thread Starter
New Member
Get the selected values of Radion Buttons & DateTimePicker
Hi, I have 3 radion buttons within in Groupbox and a DateTimePicker defined in a form as name shown below
Name Variable Name
Group Box: RBGroup n/a
Radio Buttons: rbMgr, rbSuper & rb3Op Job_Position
DateTimePicker: dtbDOB Staff_DOB
Once the user selects a date and clicks one of the radion buttons. How can I get the value and save it my variable names (eventual saved onto a record)
Please help
-
Aug 16th, 2006, 12:04 PM
#2
Re: Get the selected values of Radion Buttons & DateTimePicker
From your description, it sounds at first like you want to handle this in the click event for the radio buttons. That may not do, though. If you can be sure that the user has a valid date before they click a radio button, then you could deal with it there. However, if you can't be sure that the user has already chosen a date, then you have a more complicated problem.
I would suggest that you consider a function that is called in the click/changed/ or some other event, of all four controls. If that is all that will happen in the event, then you could combine them, but that's another issue. You might want the function to enable a button once a date and a radio button has been chosen. You could have the data stored to the variables by the function, but you shouldn't have the function save the data to a record, because the chances of the user making an error, and having all of the data stored incorrectly is much too great.
The function would first check to see whether both a valid date and a radio button have been chosen, and if not, it would simply return without doing anything. If both are present, then you can go ahead and put the data into the variables.
For the radio buttons, you can do something like this:
VB Code:
if rbMgr.Checked Then
'Set the value for rbMgr
Elseif rbSuper.Checked Then
'Set the value for rbSuper
Elseif rb3OpJob_Position.Checked Then
'Set the value for this one.
Else
Return 'Nothing was checked, don't go on.
End if
The datepicker is a bit more complicated, because there is a value by default (today). This means that a person could unintentionally set a date. If the current date is a satisfactory default, then you don't need to do much (though you should set it explicitly). At the moment, I can't think of any way to prevent people from doing this wrong that is foolproof. If you use the click event, then a person could select the wrong thing, and they'd be off and running. If you use the value changed event, then if the user wanted the currently selected date, they couldn't use it. Therefore, I think the click event would be best, but you'd have to tinker with it.
You want the dtbDOBStaff_DOB.Value property for the date chosen.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|