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!

Why does this macro not work?

Status
Not open for further replies.

cabbey77

Technical User
Aug 6, 2004
68
US
I am having a hard time understanding why this macro is not working, it tells me that the code compiles successfully, and then gives me nothing when I run the report. I have a full list of If...Thens to layer into this report, and I am stuck.

Here is the macro as written currently.

Sub Test()
If Field("NAME") = "LaFrance,James C" Then
D = "OH Mgmt"
End If
DERIVEDFIELD D
End Sub
 
ReportSmith v4.2.2 Oracle database

I use a string of these type of if statments which work for me.

The only difference I see is the $ after Field. Quoting the Macro reference manual "Field$ retrieves the value of the specified field for the record number to which the dataset of the currently active repport is pointing. This statement is always used as a function."

Sub upxstat()
If (Field$("FILE#") = "1234") Then
X = "7"
End If

DerivedField X
End Sub

David L. Black Consulting
 
Even when I put the $ it will not come up. If I change it to a numeric field it works just fine.

I have also tried using InStr$ and Left$ strictly to avoid the possible errors of spaces and commas, but nothing seems to work when I attempt to use a text field.

Im really confused.

Any other ideas? I realize I can work around this one, but for my later statements, I am not sure that I will be able to.

Thanks so much for all the help!
 
I figured out why it did not work. There was actually a different table with the field of Name, so I had to specify the table and the field.

Thanks!
 
This worked for me on our database.

Sub test()
If Field$("NAME") = "Black, David L." Then
D = "OH Mgmt"
End If
DERIVEDFIELD D
End Sub

Check the exact contents of Name field, ie comma, spaces, and period. In this example it has to be exact to what your comparing.






David L. Black Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top