Using an unbound field on a detail subform

Papashep

New member
Local time
Today, 10:55
Joined
Oct 13, 2013
Messages
15
I am using a subform to display transactions belong to an account specified on the main form. This works OK.
The problem I have is the amount of data to be displayed is to much for the size of the subform, so I thought I would resolve this using an unbound field (DisplayName) in which I want to display either the (PayeeName) or the (OriginalPayeeName) from the transaction recordset.. My idea was to control which value is displayed in the unbound field with the click of a button and the setting of a boolean variable. All I keep getting in the (DisplayName) is #NAME? can anyone advise me on how I should go about this?:banghead:
 
first thing to do is to post the code you are using, then someone can help - looks ,ike there is two lots of code - the vba behind your button click event and the code you are using in your controlsource for the displayname control
 
include both the payeename, and originalpayeename in your subform. if you don't want to show them, use the load event to hide them:

private sub form_load()
me.payeename.columnhidden = true
me.originalpayeename.columnhidden=true
end sub

use current event of the subform to display the name in the unbound textbox.

private sub form_current()
on error resume next
me.parent!displayname = iif(trim(me.payeename & "")="", me.originalpayeename, me.payeename)
end sub
 
Sorry I am not only new to using forums, but I am a real beginner when it comes to using vba

Code:

Dim CheckDisplayName as Boolean

Private Sub btnDisplayPayee_Click()
If CheckDisplayName = True Then
DisplayPayee = Nz(PayeeName, "")
CheckDisplayName = False
Else
DisplayPayee = Nz(OriginalPayeeName, "")
CheckDisplayName = True
End If
Refresh
End Sub
Private Sub DisplayPayee_Dirty(Cancel As Integer)
If CheckDisplayName = True Then
Me.PayeeName = Nz(Me.DisplayPayee, "")
Else
Me.OriginalPayeeName = Nz(Me.DisplayPayee, "")
End If
End Sub
Private Sub DisplayPayee_GotFocus()
If CheckDisplayName = True Then
CheckDisplayName = False
Me.DisplayPayee = Nz(Me.PayeeName, "")
Else
Me.DisplayPayee = Nz(Me.OriginalPayeeName, "")
CheckDisplayName = True
End If
End Sub
 
you dont need the subs Dirty and GotFocus there. also use Me.PayeeName and Me.OriginalPayeeName. Set the Locked property of DisplayPayee so it is not altered.
 

Users who are viewing this thread

Back
Top Bottom