- Local time
- Today, 14:23
- Joined
- Oct 29, 2018
- Messages
- 22,571
Hey, one step at a time. Okay? I have to run out but will check back later. Cheers!It auto-generated but when I save, record is not seen anywhere
Hey, one step at a time. Okay? I have to run out but will check back later. Cheers!It auto-generated but when I save, record is not seen anywhere
Ok.... but then I think you should know that it actually saves new record, both SN and fleetNo in the query but only save SN in the table....the fleetNo field in the table still remain blankHey, one step at a time. Okay? I have to run out but will check back later. Cheers!
Trust me sir, I need to store them in the main database table....if I can't handle the manipulation, then I'll have to manually input the FleetNo... though it will prolong my entry time....Here is another explanation from a different viewpoint.
You know the SN. The other part, "MOT/T/" is constant, according to what you tell us. You would store those six characters every time you create your desired format - but that is a waste of space and Access is optimized towards reducing wasted space. The thing about forms and reports is that they are able to operate from a query as well as a table. This gives you two options.
First, if you use a query like theDBguy showed you in post #7, you can drive reports with that constant added in to a field that you don't have to store every time.
Second, there is such a thing as adding a constant label adjacent to a data field where the constant "MOT/T/" can be displayed next to your serial number, not from the layer of the table or query, but from the layer of the form or report..
In NEITHER case will you need those extra six characters to be stored in the table. OK, you ask, what's the deal about six lousy characters? Why am I catching flak over it?
This is YOUR database and it will go wherever you steer it. But we are trying to explain a basic principle - that constant data doesn't need to be stored in a table, be it six characters or the opening paragraph to War and Peace. And we are bringing it up now because that principle applies to the question you asked.
You will find that we often try to redirect you towards more efficient use of the database. Please take it in that light. Have you ever had a parent, aunt, or uncle try to gently tell you something would be better if you did it another way?
Private Sub SerialTextboxName_Change()
Dim sValue As String
sValue = Me.SerialTextboxName.Text & ""
If sValue <> "" Then
Me.FleetTextboxname = "MOT/T/" & sValue
Else
Me.FleetTextboxname = Null
End If
End Sub
change SerialTextboxname and FleetTextboxname to correct textbox name on your form
It worked!! and saving tooif you insist, forget about the Query.
bring your form in design view.
add code to Change Event of Serial textbox:
Serial textbox:Code:Private Sub SerialTextboxName_Change() Dim sValue As String sValue = Me.SerialTextboxName.Text & "" If sValue <> "" Then Me.FleetTextboxname = "MOT/T/" & sValue Else Me.FleetTextboxname = Null End If End Sub change SerialTextboxname and FleetTextboxname to correct textbox name on your form
Private Sub SerialTextboxName_Change() Dim sValue As String
sValue = Me.SerialTextboxName.Text & ""
If sValue <> "" Then
Me.FleetTextboxname = "MOT/" & _
combo.Column(1) & "/" & sValue
Else
Me.FleetTextboxname = Null
End If
End Sub
Ah, so they were never going to always be MOT/T after all.It worked!! and saving too
Thank u sir... but then I need another manipulations...
In one of my combo boxes, there's one named permit_type with contents
Buses
Tricycle
Taxi
etc
The fleet numbers are assigned according to permit type thus
Buses. "MOT/R/[SN]
Tricycle. "MOT/T/[SN]
Taxi. "MOT/P/[SN]
Where SN is serial number just like we've worked out
Now...is it possible that I select a permit type and the fleetNo corresponds to it
i.e. if I select Buses, the fleetNo textbox autopopulates as MOT/R/[SN] after entry of SerialNo and if I select Tricycle, the fleetNo becomes MOT/T/[SN], etc
I feel like I'm asking us to journey to hell and come back
Pls help
Ah, so they were never going to always be MOT/T after all.![]()
You said...add column to "your combo"add another column to your combo and add the T, R, P to their respective row. then change:
Code:Private Sub SerialTextboxName_Change() Dim sValue As String sValue = Me.SerialTextboxName.Text & "" If sValue <> "" Then Me.FleetTextboxname = "MOT/" & _ combo.Column(1) & "/" & sValue Else Me.FleetTextboxname = Null End If End Sub
Yes one step forward, six steps backwards.
One step at a time sir....pls don't be offended
SorryYes one step forward, six steps backwards.
Just wasted everyones time because another method was required.![]()
Private Sub SerialTextboxName_Change()
Dim sValue As String
sValue = Me.SerialTextboxName.Text & ""
If sValue <> "" Then
Me.FleetTextboxname = "MOT/" & _
Me.permit_type.Column(1) & "/" & sValue
Else
Me.FleetTextboxname = Null
End If
End Sub
Love you man.... it's workingthe combo I am referring is the permit_type combo.
you add In between the list (on the combo's Row Source) "T";"R", etc., eg:
"Buses";"B";"Tricycle";"T";"Taxi";"R"
don't forget to separate them with semicolon (
still on the combo's Property->Format
Column Count: 2
Column Widths: 1";0
now change this to:
Code:Private Sub SerialTextboxName_Change() Dim sValue As String sValue = Me.SerialTextboxName.Text & "" If sValue <> "" Then Me.FleetTextboxname = "MOT/" & _ Me.permit_type.Column(1) & "/" & sValue Else Me.FleetTextboxname = Null End If End Sub
But.....can I ask you one more question?the combo I am referring is the permit_type combo.
you add In between the list (on the combo's Row Source) "T";"R", etc., eg:
"Buses";"B";"Tricycle";"T";"Taxi";"R"
don't forget to separate them with semicolon (
still on the combo's Property->Format
Column Count: 2
Column Widths: 1";0
now change this to:
Code:Private Sub SerialTextboxName_Change() Dim sValue As String sValue = Me.SerialTextboxName.Text & "" If sValue <> "" Then Me.FleetTextboxname = "MOT/" & _ Me.permit_type.Column(1) & "/" & sValue Else Me.FleetTextboxname = Null End If End Sub
ok ... tatanungin koanu tanung mo bro?
In my Permit type as earlier stated,(Bus, tricycle, mass transit, taxi, etc), Bus and Tricycle are further Divided in to Routes (for bus) and province (for tricycle) as follows;anu tanung mo bro?