Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select radio button in webbrowser control using vba

Posted on 2015-01-31
8
Medium Priority
?
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40582141
Instead of true/false, try check / uncheck.

i am looking for exact syntax now.
0
 
LVL 39

Author Comment

by:thenelson
ID: 40582145
Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked=check
produces "object doesn't support this property"
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40582148
I was hopping this will work:

Me.ocxWebBrowser.Document.All.patient_gender_value_patient_gender_m.checked

with no = True
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 39

Author Comment

by:thenelson
ID: 40582151
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
 
LVL 39

Author Comment

by:thenelson
ID: 40582161
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 34

Accepted Solution

by:
Mike Eghtebas earned 2000 total points
ID: 40582162
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
ID: 40582167
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 34

Expert Comment

by:Mike Eghtebas
ID: 40582170
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

636 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