setting box back to null

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

When i change a combo box how do i code it that it will change
txtInvoiceNumber and txtOrdernumber back to null

Thanks

Simon
 
Hi

If useing the combo to find a record on your form and then set 2 other
fields to "" use something like this

Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FormField] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub

Or, if just wanting to select from combo then set fields to "", use
something like this

Private Sub ComboName_AfterUpdate()
'Some code here - what combo will do'
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub



Hope this helps
 
Wayne-I-M said:
Hi

If useing the combo to find a record on your form and then set 2 other
fields to "" use something like this

Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FormField] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub

Or, if just wanting to select from combo then set fields to "", use
something like this

Private Sub ComboName_AfterUpdate()
'Some code here - what combo will do'
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub

Why set them to "" instead of Null, Wayne? The two aren't
interchangeable, and if these text boxes are bound to fields that don't
allow zero-length strings, setting them to "" will cause an error. If
Simon really wants to set the text boxes to Null, the code should be:

Me.txtInvoiceNumber = Null
Me.txtOrdernumber = Null
 
Hi Dirk

Yes sorry you are of course correct Null would be better and looking back at
the original question that "was" the question.

I should read the posts more carefully - I will add that to the "many,many,
many" resolutions to make on Sunday.

Happy New Year - or holidays, but I will not ask "that" question again <8-)

--
Wayne
Manchester, England.



Dirk Goldgar said:
Wayne-I-M said:
Hi

If useing the combo to find a record on your form and then set 2 other
fields to "" use something like this

Private Sub ComboName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[FormField] = " & Str(Me![ComboName])
Me.Bookmark = rs.Bookmark
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub

Or, if just wanting to select from combo then set fields to "", use
something like this

Private Sub ComboName_AfterUpdate()
'Some code here - what combo will do'
Me.txtInvoiceNumber = ""
Me.txtOrdernumber = ""
End Sub

Why set them to "" instead of Null, Wayne? The two aren't
interchangeable, and if these text boxes are bound to fields that don't
allow zero-length strings, setting them to "" will cause an error. If
Simon really wants to set the text boxes to Null, the code should be:

Me.txtInvoiceNumber = Null
Me.txtOrdernumber = Null


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top