Label

Dazza666

Registered User.
Local time
Yesterday, 16:48
Joined
Aug 13, 2008
Messages
56
Hi,

I have a label that pulls some fields from a different form
"LabelName.caption = forms.Client.FirstName"
etc

It works fine but I need the event to run when the user navigates to another record,

At the moment I have it in page_load but it obviously only updates with the first displayed record.

Can this be done?

thanks
 
Hey,

thanks for the swift response, I get a 'object doesn't support this property or method' error when I run it in the 'on current' event, this is the actual code i'm using

Label7.Caption = Forms.ReferralForm.FirstName.Value & " " & Forms.ReferralForm.Surname.Value

Any ideas?

cheers
 
Last edited:
probably the problem is that either your FirstName or Surname fields are null. In that case you can use an if statement to check whether any of the fields are none i.e.

Code:
If Not IsNull(Me.FirstName) And Not IsNull(Me.Surname) Then
Label7.Caption = 'reference the controls here
Else
Label7.Caption = 'add an alternative here
End If

You can also omit the .Value as that is used by default.
 
Thanks again but still no go.

I checked the records in the table and there are no blanks,

it's weird because it works ok in page_load?

I'm kinda stuck because I'll be relying on labels like this alot in this form!

here's the code i'm using now (line breaks due to forum not actual code)

If Not IsNull(Forms.ReferralForm.FirstName) And Not IsNull(Forms.ReferralForm.Surname) Then
Label7.Caption = Label7.Caption = Forms.ReferralForm.FirstName.Value & " " & Forms.ReferralForm.Surname.Value
Else
Label7.Caption = "Empty Record"
End If

End Sub
 
could you upload a small sample of your database i.e. the form in question?
 
Here's a quick and dirty example of a method of changing the main form caption, see if you can alter it to suit

Private Sub Form_Current()

If RecordsetClone.RecordCount > 0 Then
If Me.NewRecord Then
Me.Caption = "New Record Entry"
Else
Me.Caption = Me.txtDescr
End If
End If
Select Case Val(Me.txtCond)
Case Is > 0
Me.Command82.Visible = True
Case Else
Me.Command82.Visible = False
End Select


End Sub
 
thanks for your responses,

I have it working using the same code, but i've added the firstName and Surname fields to this form aswell and just hidden them so it has a problem referencing another form.

I can upload a picture of the other form Max, what part would be helpful, the VBA or designView?

thanks
 
I'm glad that you sorted your problem.

Since you have solved your issue there is no need to upload the sample because i was simply going to take a look where the problem was :)
 
Your original code would also bomb if the form ReferralForm wasn't open at the time. Perhaps you were inadvertently testing the code in the OnCurrent event (which is where it belonged) without having ReferralForm open?
 

Users who are viewing this thread

Back
Top Bottom