Full Version: Maybe Wrong Event
UtterAccess Forums > Microsoft® Access > Access Forms
jmcwk
Have the below code in the Before Update Event and get a 3168 Error would I be better served placing it in another Event or ?
CODE
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.Style = Me.Length.Column(1) & " - " & Me.Chassis.Column(1) & "   " & Me.WB.Column(1) & " w/" & Me.Engine.Column(1)
End Sub

Thank You
HiTechCoach
CODE
? vba.Error(3168)
pplication-defined or object-defined error


I think you may be having issues with the control names that match property names.

I would rename your controls and add the "cbo" prefix to all your combo box controls. Use "txt" as the prefix for text boxes.

Like this:

CODE
Private Sub Form_BeforeUpdate(Cancel As Integer)
     Me.txtStyle = Me.cboLength.Column(1) & " - " & Me.cboChassis.Column(1) & "   " & Me.cboWB.Column(1) & " w/" & Me.cboEngine.Column(1)
End Sub


Without renaming your controls try:

CODE
Private Sub Form_BeforeUpdate(Cancel As Integer)
     Me.[Style] = Me.[Length].Column(1) & " - " & Me.[Chassis].Column(1) & "   " & Me.WB.Column(1) & " w/" & Me.[Engine].Column(1)
End Sub




Edited by: HiTechCoach on Tue Feb 26 14:24:49 EST 2008.
jmcwk
Thank You Boyd,
Sent with this:
CODE
Me.[Style] = Me.[Length].Column(1) & " - " & Me.Chassis.Column(1) & "   " & Me.WB.Column(1) & " w/" & Me.[Engine].Column(1)

Only thing is that it would be nice to display as the user Entrs the Value(s) Style is a Bound Control I guess I could set its visible property to No and place a Field in the Query with something like:
CODE
Sty: [Length] & " - " & [chassis] & "   " & [WB] & " w/ " & [Engine]
HiTechCoach
In the after update event of all the combo boxes you will need to run this:
!--c1-->
CODE
Me.[Style] = Me.[Length].Column(1) & " - " & Me.Chassis.Column(1) & "   " & Me.WB.Column(1) & " w/" & Me.[Engine].Column(1)

If you are not saving the data then maybe try setting the control source for [Syle]
CODE
= Me.[Length].Column(1) & " - " +Me.Chassis.Column(1) & "   "+Me.WB.Column(1) & " w/" +Me.[Engine].Column(1)
jmcwk
Thank You Boyd,
tyle is a needed Value and needs to be saved at the demand of the user(s) if it was solely up to me I would use Sty within the Query grid as I guess in a sense it is a calculated value ???
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.