Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Pulling Strings apart

Status
Not open for further replies.

joeyh

Programmer
Nov 13, 2000
12
0
0
US
It's me again. I thought that I had solved my problem but I didn't. This is how the function looks.

Function Seperate(Field)
Field = Cstr(Field)
RSpace = InStr(Field, " ")
Field = Left(Field, RSpace - 1)
Seperate = Field
End Function

It gives me an error saying:
Invalid procedure call or argument: 'Left'

The wierdest thing that I found out was, if I did it like this:

Function Seperate(Field)
Field = Cstr(Field)
RSpace = InStr(Field, " ")
Field = Left(Field, 2)
Seperate = Field
End Function

it worked with no problem. The thing is I do not know how many characters from the left I will need. Whether it is 2 or 1 or ever how many. This is the blindfold nature of programming.
Any help will be appreciated.
Thanks
Joeyh
 
i don't know anything about vbscript... but maybe you might want to try to use parseint on rspace before you subtract 1.
 
Didn't the answer I supplied in the other post work? Will your field always contain a space?

nick bulka

 
Nick,

I haven't had a chance to try Clng, but I will and will post back here if it works or if it doesn't. Yes the field will always contain a space. What I am doing is developing an API to update a MS Access database. I have two tables. One table has fields:
Attach_id
Attachment

I have a drop down menu that supplies both of the fields.
This is the way it looks when the function is called.

1 mowers
2 boxblades

and so on.
The reason I am doing this is because The relationship in the other table is linked to the attach_id in the other.
This way the persons updating the database will not have to know the attach_id number in the main table. I am not very good at explaining, but maybe you will understand what I am doing.
Joeyh
 
joey, try this:
============

Function Seperate(Field)
fieldVal = Cstr(Field)
spaceLocale = InStr(Field, " ")
fieldVal = Mid(Field, (spaceLocale-1) )
Seperate = fieldVal
End Function

============
 
The mid did not work. I get a invalid procedure call or argument no matter what I use. I believe I going to give up because I do not think I can do it in VBScript. I can do it all day long in Visual Basic, nut if anyone else has any suggestions, please let me know.
Thanks,
Joeyh
 
The mid did not work. I get a invalid procedure call or argument no matter what I use. I believe I going to give up because I do not think I can do it in VBScript. I can do it all day long in Visual Basic, but if anyone else has any suggestions, please let me know.
Thanks,
Joeyh
 
the code looks syntactically correct. again, I'll suggest testing to make sure that the instr function is returning a positive value. This is something you should ALWAYS do, even if you always expect a non-zero value. It's just good programming.

nick bulka

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top