Cant get code to work

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I have a dropdown list which I select a "Handler". When I select a
"Handler" (HCode" is control Source) the "HCode" is automatically inserted
into the "HCode" textbox. I can get this to work. But I also need to have
the "AccountNumber" automatically inserted into the "AccountNumber" textbox.
I have tried adding the 3rd line in the code below but can't get it to
insert the "AccountNumber". The "HCode" shows up instead. What am I doing
wrong...Thanks...Randy

SELECT [Handlers].[HandlerID], [Handlers].[Handler], [Handlers].[HCode],
[Handlers].[AccountNumber] FROM [Handlers]

Column Count: 4
Column Widths: 0";2.5";0";0.5646"
Bound Column: 3

Private Sub Handler_AfterUpdate()
Me.HCode = Me![Handler].Column(2)
Me.HCode = Me![AccountNumber].Column(4)
End Sub
 
Randy,

First off, seems to me that your bound column should be 1, assuming that
HandlerID is your PK. Secondly, your code is assigning two different values
to one text box. Perhaps you meant:

Me.HCode = Me![Handler].Column(2)
Me.AccountNumber = Me![Handler].Column(4)

HTH,
Jeff
 
Oops,
**** Me.AccountNumber = Me![Handler].Column(4) is wrong ****
column count starts at zero
Me.AccountNumber = Me![Handler].Column(3) is correct
Jeff

JeffW said:
Randy,

First off, seems to me that your bound column should be 1, assuming that
HandlerID is your PK. Secondly, your code is assigning two different values
to one text box. Perhaps you meant:

Me.HCode = Me![Handler].Column(2)
Me.AccountNumber = Me![Handler].Column(4)

HTH,
Jeff
SELECT [Handlers].[HandlerID], [Handlers].[Handler], [Handlers].[HCode],
[Handlers].[AccountNumber] FROM [Handlers]

Column Count: 4
Column Widths: 0";2.5";0";0.5646"
Bound Column: 3

Private Sub Handler_AfterUpdate()
Me.HCode = Me![Handler].Column(2)
Me.HCode = Me![AccountNumber].Column(4)
End Sub
 
Thanks Jeff, That worked
JeffW said:
Oops,
**** Me.AccountNumber = Me![Handler].Column(4) is wrong ****
column count starts at zero
Me.AccountNumber = Me![Handler].Column(3) is correct
Jeff

JeffW said:
Randy,

First off, seems to me that your bound column should be 1, assuming that
HandlerID is your PK. Secondly, your code is assigning two different values
to one text box. Perhaps you meant:

Me.HCode = Me![Handler].Column(2)
Me.AccountNumber = Me![Handler].Column(4)

HTH,
Jeff
SELECT [Handlers].[HandlerID], [Handlers].[Handler], [Handlers].[HCode],
[Handlers].[AccountNumber] FROM [Handlers]

Column Count: 4
Column Widths: 0";2.5";0";0.5646"
Bound Column: 3

Private Sub Handler_AfterUpdate()
Me.HCode = Me![Handler].Column(2)
Me.HCode = Me![AccountNumber].Column(4)
End Sub
 
Back
Top