• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

select radio button in webbrowser control using vba

I have a webpage with the following code:
<label><input type="radio" name="patient_gender" value="patient_gender_m" id="patient_gender_value_patient_gender_m" />Male</label>
<label><input type="radio" name="patient_gender" value="patient_gender_f" id="patient_gender_value_patient_gender_f" />Female</label>

Open in new window

I would like to select the male or female radio button as appropriate.

What is the correct code to do this?

I have successfully filled input boxes on the page with code like:
Me.ocxWebBrowser.Document.Forms(0).patient_fname.Value = "Nelson"

Open in new window


These create the error "object doesn't support the property:
Me.ocxWebBrowser.Document.Forms(0).patient_gender_value_patient_gender_m.checked=true
Me.ocxWebBrowser.Document.Forms(0).patient_gender_value_patient_gender_m.click

Open in new window

0
thenelson
Asked:
thenelson
  • 4
  • 4
1 Solution
 
Mike EghtebasDatabase and Application DeveloperCommented:
Instead of true/false, try check / uncheck.

i am looking for exact syntax now.
0
 
thenelsonAuthor Commented:
Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked=check
produces "object doesn't support this property"
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
I was hopping this will work:

Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked

with no = True
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
thenelsonAuthor Commented:
Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked
produces "object doesn't support this property"

not sure what you mean by:
with no = True
0
 
thenelsonAuthor Commented:
I found my problem. The correct syntax is:
       Me.ocxWebBrowser.Document.Forms(0).patient_gender_value_patient_gender_m.Click
but the webpage I am trying to interface with changes the name of the gender radio button depending upon which form is called up. I some cases it is:
     patient_gender_value_patient_gender_m
while other forms (for the same page), its:
     gender_value_gender_m

The other field id's remain the same between the forms.
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
In c# and vb.net, in code behind for asp.net project, the object like patient_gender_value_patient_gender_m will have a method checked(). This way you complete the code using patient_gender_value_patient_gender_m.checked(); without = true or false.

Using that concept, I was wishfully thinking Access is also has transformed and adopting this approach. Apparently not.

I just saw your latest post. So, it has Click() event not Checked() event.
0
 
thenelsonAuthor Commented:
Yes, the Click property is used. I was running into problems because the website pulls up different forms for different insurance companies. Although the ID's for the textboxes stay the same from form to form, the gender radio buttons ID's change for different forms. So sometimes the Click property worked and sometimes it didn't.

Thanks for your input.
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
You are welcome. Thank you for the points.

Also for the record, I called event while I should have said method.

I wonder if it will work with () like:

Me.ocxWebBrowser.Document.Forms(0).patient_gender_value_patient_gender_m.Click()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now