Setting Variables

LadyDi

Registered User.
Local time
Yesterday, 23:59
Joined
Mar 29, 2007
Messages
894
I am trying to set some variables in VBA so that I can add them to a URL for a Active X control. However, the debugger keeps telling me that "an object is required". I don't understand what it wants. If someone could help me, I would really appreciate it. Here is the code I am trying to use:

Code:
Dim strURL As String
   Dim HTML As Object
   Dim AirportCode As String
   Dim WeatherDate As String
 
   Set AirportCode = Me.Text1
   Set WeatherDate = Me.Text4
   
   Set strURL = "[URL]http://www.wunderground.com/history/airport/[/URL]" & AirportCode & WeatherDate & "CustomHistory.html"
   Set HTML = Me.WebBrowser0.Object
   HTML.navigate strURL

It doesn't seem to like my first two Set statements. Those are what it highlights.

I know the field names are very generic, that is because I was just trying to test this and have not assigned meaningful names yet. Text1 and Text4 are just a couple of text boxes and WebBrowser0 is my ActiveX control. I thought I would see if I could get it to work before I renamed anything.
 
Try simply

AirportCode = Me.Text1
 
That worked perfectly. Thank you very much.
 
"Set" is for objects. It assigns a pointer to the object.

The VBA keyword for assigning a value to an ordinary varlaible is actually "Let" but it is understood automatically when omitted so nobody bothers to use it.

Let x = 1
 

Users who are viewing this thread

Back
Top Bottom