Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate text box with "If...then...else...end if" ?

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
:) s-) (-:

Hi,
I apologize for not being more familiar with VB, but in the meantime could someone help with this? (If there is no check number, then display the deposit number; if there is no deposit number, then display the other number; if there is no number at all; then display blank.)

Code:
If CheckNumber = true then
   txtboxID = CheckNumber
Else if
   DepositNumber = true then
      txtboxID = DepositNumber
Else if
   OtherNumber = true then
      txtboxID = OtherNumber
Else
   txtboxID = ""
End if

If someone could translate my pigeon basic into VB I would be so grateful, and I solemnly promise...or perhaps...

Code:
Begin Case txtboxID
  Case CheckNumber
    txtboxID = CheckNumber
  Case DepositNumber
    txtboxID = DepositNumber
  Case OtherNumber
    txtboxID = OtherNumber
  Case 1
    txtboxID = "Punt"
End Case

Yep, I'm goin' nuts.
:) s-) (-:
Gus Brunston
An old PICKer
padregus@home.com
 
If IsNull(CheckNumber) = False Then
txtboxID = CheckNumber
Else if
IsNull(DepositNumber) = False Then
txtboxID = DepositNumber
Else if
IsNull(OtherNumber) = False Then
txtboxID = OtherNumber
Else
txtboxID = ""
End if

HTH Joe Miller
joe.miller@flotech.net
 
Dear Joe:
That really looks good. I copied it to code (I selected the unbound "txtboxID" and ended up copying the code to "BeforeUpdate" event. Is that right?)
The second phrases (following the "Else ifs...") appeared in red...I forget what that means.
But textboxID doesn't display any numbers. Did I put it in the wrong place? should txtboxID be bound to a field? (I just want to display numbers, not change them.)
Thanks if you can spot what my trouble is, and thanks anyway for your attention to my thread.
:) Gus Brunston
An old PICKer
padregus@home.com
 
Sorry, forgot to take out the spaces! As for the event, not really sure which event to use based on info given. Try out BeforeUpdate, OnCurrent possibly. Here's the updated code:

If IsNull(CheckNumber) = False Then
txtboxID = CheckNumber
ElseIf
IsNull(DepositNumber) = False Then
txtboxID = DepositNumber
ElseIf
IsNull(OtherNumber) = False Then
txtboxID = OtherNumber
Else
txtboxID = ""
End if Joe Miller
joe.miller@flotech.net
 
Joe,
Thanks very much for your help...I just couldn't get that all to work. I'm going to take a couple of days and dig into what makes VB tick. It's not very "Visual" for me yet.
:) Gus Brunston
An old PICKer
padregus@home.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top