IF Statement should detrmne which recrds to make visible but not w

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

Guest

Hey Guyz,

Pls help me out. I’m a COMPLETE novice with programming but can string one
or two lines together (might not seem that way from what I’m about to ask
though):

Riiight, so I have a form that runs off a straight-forward table. This form
shows vehicle transfer bookings.

Each booking has a "message" field that will later be linked to a
cellphone-txt-message system but for now im happy with just having that
"message" text box, as is, as the user will just copy and paste the text to
the third party software to transmit the message via cellphone.

This message will be sent to the driver to inform him of his next job btw.

Anyway, so here's the situation/problem:

My "Message" text box is a TRIM of multiple fields and text strings (that
works perfectly though thanks!)

There are 5 kinds of possible messages and i want to ONLY display the
relevant message to the user for each line/entry. (The form is a Continuous
Form)

EG: If you booked a "Chauffer Drive" the Chauffer Drive Message would come
up and if you booked a "Point-to-Point" the Point-to-Point message would come
up. (This would be different throughout the lines as different clients book
different kinds of transfers) (sorry if im stating the obvious)

One of the fields in the table that this form runs off determines which
message is the correct one.

This field is called numTransferType

So heres my question: how do i display only the correct "Message" as appose
to all of them in each individual line?

This is my code - please dont laugh - Like i said; HUGE NOVICE!!!

Private Sub Form_Load()
If numTransferType.Value = 1 Then 'Chauffer Drive
txtPointToPointDriver.Visible = False
txtAirportCollectionDriver.Visible = False
txtAirportDropOffDriver.Visible = False
txtChaufferDriver.Visible = True
txtTourDriver.Visible = False
End If

If numTransferType.Value = 2 Then 'Point-to-Point
txtPointToPointDriver.Visible = True
txtAirportCollectionDriver.Visible = False
txtAirportDropOffDriver.Visible = False
txtChaufferDriver.Visible = False
txtTourDriver.Visible = False
End If

If numTransferType.Value = 3 And blnArrival.Value = Yes Then 'Airport
Arrival
txtPointToPointDriver.Visible = False
txtAirportCollectionDriver.Visible = True
txtAirportDropOffDriver.Visible = False
txtChaufferDriver.Visible = False
txtTourDriver.Visible = False
End If

If numTransferType.Value = 3 And blnDeparture.Value = Yes Then 'Airport
Drop Off
txtPointToPointDriver.Visible = False
txtAirportCollectionDriver.Visible = False
txtAirportDropOffDriver.Visible = True
txtChaufferDriver.Visible = False
txtTourDriver.Visible = False
End If

If numTransferType.Value = 3 Then 'Tour
txtPointToPointDriver.Visible = False
txtAirportCollectionDriver.Visible = False
txtAirportDropOffDriver.Visible = False
txtChaufferDriver.Visible = False
txtTourDriver.Visible = True
End If

End Sub

When I open the form (for some strange reason) ONLY the TOUR “Messageâ€
appears throughout ALL the lines and I can honestly not figure out why that
is!

(I plan on positioning all the messages on top of each other so that only
the valid message for each line would appear)

Thanks sooooooo much in advance for reading my rather LONG question. Hope I
made sense!

Cheers!

Ant
 
Use the form's Current event.

The Load event only fires when the form first loads.
 
Hey Allen,

Thanks for the reply. I tried it and it doesnt really do what i want it to.
Basically whats happening now is that when i click in each line the messages
move to the correct message though still displays the remainder of the
messages.

I was thinking: shouldnt i just be writing the TRIM code with a unbound
text box and then write an if stating which code should display?
 
If your form is in Form view (not Continuous or Datasheet view), your code
should show some text boxes and hide others when you use Form_Current.

There may be an easier way to do this. You probably have a table with a
record for each value for numTransferType. You may be able to create a
related table with the messages relevant to that numTransferType, and then
display them in a subform instead of trying to show/hide them in the main
form. (To do this you would need to separate numTransferType 3 into 2
values, say 3 = "airport drop off", and 4 = "airport tour".)
 
Back
Top