Label Problem!

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

--
I want label87 to test Text Box [tbBank] , so if there is no data in it
Label87 will be blank,
Where would I put this code.................Thanks Bob
Label87.Visible = Len([tbBank] & vbNullString)>0
 
Sorry Tom this is for my Report not a Form
Regards and thanks Bob

Tom Wickerath said:
Hi Bob,

Try using the Form's Current event procedure:

Private Sub Form_Current()
On Error GoTo ProcError

Label87.Visible = Len([tbBank] & vbNullString) > 0

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


I also recommend giving this label a better name, so that your code will
be
more easily read and understood in the future.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Bob said:
I want label87 to test Text Box [tbBank] , so if there is no data in it
Label87 will be blank,
Where would I put this code.................Thanks Bob
Label87.Visible = Len([tbBank] & vbNullString)>0
 
Use the Format Event of the Section in which the TextBox & the Label reside
....
 
Hi Bob,

Here is an example that works for a label named label87 in the report's
detail section:

Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ProcError

Label87.Visible = Len([tbBank] & vbNullString) > 0

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


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Tom Absolutely FANTASTIC ;)
So if I want to do this to multiple labels testing on different Text boxes,
will I just keep adding that code and change parameters or should they all
be together....Thanks Bob

Tom Wickerath said:
Hi Bob,

Here is an example that works for a label named label87 in the report's
detail section:

Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ProcError

Label87.Visible = Len([tbBank] & vbNullString) > 0

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


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Bob said:
Sorry Tom this is for my Report not a Form
Regards and thanks Bob
 
Ok this is working , does it look Ok to you ...Thanks very Much....Bob
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ProcError

lbBankName.Visible = Len([tbDirectBank] & vbNullString) > 0
lbBranch.Visible = Len([tbDirectBank] & vbNullString) > 0
lbAccountName.Visible = Len([tbDirectBank] & vbNullString) > 0


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


Bob said:
Tom Absolutely FANTASTIC ;)
So if I want to do this to multiple labels testing on different Text
boxes, will I just keep adding that code and change parameters or should
they all be together....Thanks Bob

Tom Wickerath said:
Hi Bob,

Here is an example that works for a label named label87 in the report's
detail section:

Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ProcError

Label87.Visible = Len([tbBank] & vbNullString) > 0

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


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Bob said:
Sorry Tom this is for my Report not a Form
Regards and thanks Bob
 
Great thanks for the help.....Bob

Tom Wickerath said:
Looks fine to me.
See how renaming your labels improves the readability of your code?


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Bob said:
Ok this is working , does it look Ok to you ...Thanks very Much....Bob
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ProcError

lbBankName.Visible = Len([tbDirectBank] & vbNullString) > 0
lbBranch.Visible = Len([tbDirectBank] & vbNullString) > 0
lbAccountName.Visible = Len([tbDirectBank] & vbNullString) > 0


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

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

Similar Threads


Back
Top