Adding a 3rd Argument

B

Bob Vance

At the moment if tbName is blank I am getting Father,Mother,age,sex I want
to add if tblCompanyInfo.StudVersion = true to get Age,Mother
tblCompanyInfo is not bound to the form

=IIf([tbName].[Value]="" Or IsNull([tbName].[Value]),[tbFatherName].[Value]
& "--" & [tbMotherName].[Value] & " " & [tbAge].[Value] & " " &
[cbSex].[Value],[tbName].[Value])

=IIf([tbName].[Value]="" Or IsNull([tbName].[Value]), &
tblCompanyInfo.StudVersion = True ([tbName].[Value],[tbAge].[Value] & " " &
[tbMotherName].[Value],[tbName].[Value])
 
T

Tom Wickerath

Hi Bob,

As you can see, these IIF statements can quickly become rather unwieldy and
difficult to maintain. Perhaps you would be better off to use the
Form_Current procedure to calculate your desired expression, and then stuff
it into the desired text box. Something like this (untested "air code"):

Private Sub Form_Current()
On Error GoTo ProcError

Dim strText As String

If Len(tbName & "") = 0 Then 'No entry in tbName
strText = tbFatherName & "--" & tbMotherName _
& " " & tbAge & " " & cbSex
Else
strText = tbName
End If

Select Case StudVersion
Case True
strText = strText & [Another Field?]
Case False 'or Case Else
strText = strText & "whatever"
End Select

Me.TextBoxName = strText

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_Current..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 

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