Can't change text box 'after update'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi There,

Apologies for the newbie question, but I am creating a form where I need to
update a textbox with data from existing columns, MailingFormatWeightStart
and MailingFormatWeightEnd, in a table called tblMailingFormat.

When I run the code and select an option from the combobox, it won't update
the two textboxes. The code is below, and I will gratefully accept any tips
for best practice for how I've done the code.

Private Sub cboMailingFormat_AfterUpdate()

Dim intMailoption As Integer, intWeightStart As Integer, intWeightEnd As
Variant

intMailoption = Me.cboMailingFormat
intWeightStart = DLookup("[MailingFormatWeightStart]", "tblMailingFormat",
"[MailingFormatID] =" & intMailoption)
intWeightEnd = DLookup("[MailingFormatWeightEnd]", "tblMailingFormat",
"[MailingFormatID] = " & intMailoption)

' 1 = Letters 2 = Flats 3 = Packets 4 = Light M-Bags 5 = Heavy M-Bags as in
tblMailingFormat

If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0 _
Then Me.TxtWeightBandStart = intWeightStart And Me.TxtWeightBandEnd =
intWeightEnd



End Sub

Can anyone help me on this one? Thanks in advance!
 
If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0
I doubt that either are 0. Try testing for Null or Zero.
If Nz(Me.TxtWeightBandStart,0) = 0 And Nz(Me.TxtWeightBandEnd,0) = 0
 
Hmm, forgo about 'Null'. I'll give that a crack tomorrow. Thanks for your
input,

K

Klatuu said:
If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0
I doubt that either are 0. Try testing for Null or Zero.
If Nz(Me.TxtWeightBandStart,0) = 0 And Nz(Me.TxtWeightBandEnd,0) = 0
--
Dave Hargis, Microsoft Access MVP


Kamitsukenu said:
Hi There,

Apologies for the newbie question, but I am creating a form where I need to
update a textbox with data from existing columns, MailingFormatWeightStart
and MailingFormatWeightEnd, in a table called tblMailingFormat.

When I run the code and select an option from the combobox, it won't update
the two textboxes. The code is below, and I will gratefully accept any tips
for best practice for how I've done the code.

Private Sub cboMailingFormat_AfterUpdate()

Dim intMailoption As Integer, intWeightStart As Integer, intWeightEnd As
Variant

intMailoption = Me.cboMailingFormat
intWeightStart = DLookup("[MailingFormatWeightStart]", "tblMailingFormat",
"[MailingFormatID] =" & intMailoption)
intWeightEnd = DLookup("[MailingFormatWeightEnd]", "tblMailingFormat",
"[MailingFormatID] = " & intMailoption)

' 1 = Letters 2 = Flats 3 = Packets 4 = Light M-Bags 5 = Heavy M-Bags as in
tblMailingFormat

If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0 _
Then Me.TxtWeightBandStart = intWeightStart And Me.TxtWeightBandEnd =
intWeightEnd



End Sub

Can anyone help me on this one? Thanks in advance!
 
Hi again,

it's still not working; should I set the default to '0' in the control
property?

Klatuu said:
If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0
I doubt that either are 0. Try testing for Null or Zero.
If Nz(Me.TxtWeightBandStart,0) = 0 And Nz(Me.TxtWeightBandEnd,0) = 0
--
Dave Hargis, Microsoft Access MVP


Kamitsukenu said:
Hi There,

Apologies for the newbie question, but I am creating a form where I need to
update a textbox with data from existing columns, MailingFormatWeightStart
and MailingFormatWeightEnd, in a table called tblMailingFormat.

When I run the code and select an option from the combobox, it won't update
the two textboxes. The code is below, and I will gratefully accept any tips
for best practice for how I've done the code.

Private Sub cboMailingFormat_AfterUpdate()

Dim intMailoption As Integer, intWeightStart As Integer, intWeightEnd As
Variant

intMailoption = Me.cboMailingFormat
intWeightStart = DLookup("[MailingFormatWeightStart]", "tblMailingFormat",
"[MailingFormatID] =" & intMailoption)
intWeightEnd = DLookup("[MailingFormatWeightEnd]", "tblMailingFormat",
"[MailingFormatID] = " & intMailoption)

' 1 = Letters 2 = Flats 3 = Packets 4 = Light M-Bags 5 = Heavy M-Bags as in
tblMailingFormat

If Me.TxtWeightBandStart = 0 And Me.TxtWeightBandEnd = 0 _
Then Me.TxtWeightBandStart = intWeightStart And Me.TxtWeightBandEnd =
intWeightEnd



End Sub

Can anyone help me on this one? Thanks in advance!
 
Back
Top