String to integer

vba Portugal
  • 14 years ago


    I want to do something like this


    Pass the field in "Answer_01" to temp1.

    But WorkRS1.fields("Answer_01") is in string variable.

    str = "WorkRS1.Fields(""Answer_" & i & """)"

    temp1 = str

    This instruction gives me a type missmatch!!!

    How can i resolve this?


  • 14 years ago


    Assuming you are refering by WorkRS1 to a recordset, the problem my friend is that you have assigned a string paprameter to the property .FIELDS where only numbers are allowed. So you need to use the relevent number of the field and not its name in order for this property to work, in this case it should look something like this:

    Dim i as integer

    Dim temp1 as string


    If you provide me with more information about what are you doing I may be able to further help you.


    Hope this works for you.

  • 14 years ago

    From your coding i came to know that ur trying to store the field value to a variable.

    also u told that a string contains right side exp.


    if u are trying to execute the string content as recordset. it wont work in VB. Actually why you need to run like this, no one programming lang support like this. bcoz recordset is an object and fields is an collection from recordset object you cannot execute the string like recordset.fields().....

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“You can stand on the shoulders of giants OR a big enough pile of dwarfs, works either way.”