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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA's equivalent to Foxpro's macro substitution? 1

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
0
0
US
The following getvalue function returns the contents of a specific table/record contents:

? Getvalue("ap2gldesc") = alltrim(code)+" ~ "+vno+" ~ "+po+" ~ "+vendor

If Trim(Getvalue("ap2gldesc")) <> "" Then
.Fields("gldesc").VALUE = Trim(Getvalue("ap2gldesc"))
End If
results in the gldesc field = alltrim(code)+" ~ "+vno+" ~ "+po+" ~ "+vendor NOT COOL!

With Foxpro: setup5 = "replace table.gldesc with Trim(Getvalue("ap2gldesc"))"
&setup5

Please help me do the same thing with VBA.

Thanks in advance.

Steve
 
>? Getvalue("ap2gldesc") = alltrim(code)+" ~ "+vno+" >~ "+po+" ~ "+vendor
I assume this is intended to mean that the function GetValue uses the expression on the right of the = to calculate the result

If so, then I don't see what the issue is with:
>results in the gldesc field = alltrim(code)+" ~ "+vno+" >~ "+po+" ~ "+vendor NOT COOL!

Why is this not the result you expect?
 
after assigning a memvar the following:

msetup = "replace table.gldesc with table.code +
" ~ " + table.vno + " > ~ " + table.po + " ~ "
+ table.vendor

I want to run what's inside of the memvar. With Foxpro I use a macro substitution to achieve my objective.

Thanks for your reply.

Steve


 
So are you saying that if on a given record:
table.code = 1234
table.vno = 5678
table.po = 9012
table.vendor = "myvendorname" then
you want to replace the contents of the field gldesc with:
1234~5678>~9012~myvendorname
 
You can use either SQL or VBA recordsets to perform ann update. This example uses SQL.
The precise syntax depends on the field datatypes (number or text). This example has vendor as text and the others as number.

dim strsql
strsql = "Update table set gldesc = table.code " & "~" & table.vno & "<#" & table.po & "~'" & table.vendor & "'"
currentdb.execute stsrsql, dbfailonerror
 
Isn't the correct syntax like this ?
strsql = "UPDATE
SET gldesc=table.code & ' ~ ' & table.vno & ' > ~ ' & table.po & ' ~ ' & table.vendor"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top