Query

M

mareo

I have a table that have the following fields:

ID Conc
Test1 1
Test2 5
Test3 10
Test4 15
Test1 2
Test2 2
Test4 9

I want a statement that look like this:

If Test1 < 2 then PLace "nd" in [new field]
If Test2 < 1.5 then place "nd" in [new field]
If Test3 < 1 then place "nd" in [new field]
If Test4 < 10 then place "nd" in [new field]

The resulted table should look like this.

ID Conc newfield
Test1 1 "nd"
Test2 5
Test3 10
Test4 15
Test1 2
Test2 2 "nd"
Test4 9 "nd"

How can I accomplish this task?

Thanks
 
L

Les

This should work. Create a new query. Include ID, Conc,
and create a new field.

newfld: retval([ID],[Conc])

Create a new module, and copy the following into it.

Public Function retval(ID1, Conc1) As String

If (ID1 = "Test1") Then
If (Conc1 < 2) Then
retval = "nd"
Else
retval = " "
End If
End If

If (ID1 = "Test2") Then
If (Conc1 < 1.5) Then
retval = "nd"
Else
retval = " "
End If
End If

If (ID1 = "Test3") Then
If (Conc1 < 1) Then
retval = "nd"
Else
retval = " "
End If
End If

If (ID1 = "Test4") Then
If (Conc1 < 1) Then
retval = "nd"
Else
retval = " "
End If
End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top