Coding a text box

B

Bob

Hi I have a text box which I want to pick up the data from field1 if this
IsNull (blank) then I want it to pick up the data from field2. When the
report opens, how do I go about it?

I have tried the following on the reports open event.

If me. Field1 IsNull Then
Me. Text58 = Me.Field2
Else
Me.Text58 = Field1
End If

It didn't work of course where am I going wrong?

Thanks Bob
 
B

Brendan Reynolds

"If IsNull(Me.Field1) Then" should work - IsNull() in VBA, IS NULL (with a
space) in SQL. Alternatively, you could use the NZ function, for example,
use an expression such as the following in the Control Source property of
"Text58" ...

= NZ([Field1], [Field2])
 
B

Bob

Brendan I like the = NZ([Field1], [Field2]) idea but if Field1 is blank I
get an Error in the Text box, other wise it gives the correct result. Any
ideas?

Thanks Bob


Brendan Reynolds said:
"If IsNull(Me.Field1) Then" should work - IsNull() in VBA, IS NULL (with a
space) in SQL. Alternatively, you could use the NZ function, for example,
use an expression such as the following in the Control Source property of
"Text58" ...

= NZ([Field1], [Field2])

--
Brendan Reynolds


Bob said:
Hi I have a text box which I want to pick up the data from field1 if this
IsNull (blank) then I want it to pick up the data from field2. When the
report opens, how do I go about it?

I have tried the following on the reports open event.

If me. Field1 IsNull Then
Me. Text58 = Me.Field2
Else
Me.Text58 = Field1
End If

It didn't work of course where am I going wrong?

Thanks Bob
 
D

dbl

Brendan thanks for all your help, I have now sorted it.

It works fine.

Thanks again Bob

Bob said:
Brendan I like the = NZ([Field1], [Field2]) idea but if Field1 is blank I
get an Error in the Text box, other wise it gives the correct result. Any
ideas?

Thanks Bob


Brendan Reynolds said:
"If IsNull(Me.Field1) Then" should work - IsNull() in VBA, IS NULL (with
a space) in SQL. Alternatively, you could use the NZ function, for
example, use an expression such as the following in the Control Source
property of "Text58" ...

= NZ([Field1], [Field2])

--
Brendan Reynolds


Bob said:
Hi I have a text box which I want to pick up the data from field1 if
this IsNull (blank) then I want it to pick up the data from field2. When
the report opens, how do I go about it?

I have tried the following on the reports open event.

If me. Field1 IsNull Then
Me. Text58 = Me.Field2
Else
Me.Text58 = Field1
End If

It didn't work of course where am I going wrong?

Thanks Bob
 

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