Solved

select radio button in webbrowser control using vba

Posted on 2015-01-31
8
325 Views
Last Modified: 2015-01-31
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
Comment
Question by:thenelson
  • 4
  • 4
8 Comments
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
Instead of true/false, try check / uncheck.

i am looking for exact syntax now.
0
 
LVL 39

Author Comment

by:thenelson
Comment Utility
Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked=check
produces "object doesn't support this property"
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
I was hopping this will work:

Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked

with no = True
0
 
LVL 39

Author Comment

by:thenelson
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 39

Author Comment

by:thenelson
Comment Utility
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
 
LVL 33

Accepted Solution

by:
Mike Eghtebas earned 500 total points
Comment Utility
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
 
LVL 39

Author Comment

by:thenelson
Comment Utility
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
 
LVL 33

Expert Comment

by:Mike Eghtebas
Comment Utility
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now