Combo Box selection populates text box

C

copprtop116

Long time viewer, first time participant. Love the site, it is immensely
helpful.

Situation. I inherited a database in which depending on the selection chose
from a combo box on a form, a text box on the same form would be completed
with the desired verbiage which can be altered. The creator used an "event
procedure" on the combo box "after update" that will use a statement to fill
in the data.
"Phase" is the combo box and "PhaseDetails" is the text box.

"After Update" vb Code:
Private Sub Phase_AfterUpdate()
If Me![Phase] = "Student 1" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of White
Milk" & vbCrLf & "1 - Afternoon Snack"
ElseIf Me![Phase] = "Student 2" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
Chocolate Milk" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
ElseIf Me![Phase] = "Student 3" Then
Me![PhaseDetails] = "1 - Alphabet Coloring Book" & vbCrLf & "2 - Pints
of Milk (choice)" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
End If
End Sub

Now by the time I get to the upper grades, the list of items becomes very
long. And the text in vb code can not be formatted or spaced properly so the
words do not align and the text box verbiage looks sloppy.

My attempt was to use an external word doc for these long phase details. Now
is this possible? Will the text of that imported word doc show up in the
phase details table?

Any help, ideas or suggestions would be greatly appreciated.
Thanks!
color me extremely frustrated!
 
K

Ken Snell \(MVP\)

Create a table..name it tblPhaseDetails. Put two fields in it: Phase (Text
255) and PhaseDetail (either Text 255 or Memo (if text will exceed 255
characters).

Put the phase value strings into the first field, and the longer text for
phase details in the second field; you can enter a new line (the combination
of carriage return and line feed characters) by pressing Ctrl+Enter when
typing the data into the field. Create one record for each option that is in
the first combobx.

Then change your code to this:

Private Sub Phase_AfterUpdate()
Me![PhaseDetails] = DLookup("PhaseDetail", "tblPhaseDetails", _
"[Phase]='" & Me![Phase] & "'")
End Sub
 
C

copprtop116

Thanks Ken,
that is much easier.
However a small problem. When the information is added, the rows don't
always line up. I'd like to have the information align like tab settings in
word. Sometimes they are off by half a space. Is there any way to add half a
space?

1 - coloring book
1 - pint of milk
1 - afternoon snack

Is this possible? Is there such a thing as tab settings?
Thank you ever so much, I'll cherish my remaining hair follicles.
Lori


Ken Snell (MVP) said:
Create a table..name it tblPhaseDetails. Put two fields in it: Phase (Text
255) and PhaseDetail (either Text 255 or Memo (if text will exceed 255
characters).

Put the phase value strings into the first field, and the longer text for
phase details in the second field; you can enter a new line (the combination
of carriage return and line feed characters) by pressing Ctrl+Enter when
typing the data into the field. Create one record for each option that is in
the first combobx.

Then change your code to this:

Private Sub Phase_AfterUpdate()
Me![PhaseDetails] = DLookup("PhaseDetail", "tblPhaseDetails", _
"[Phase]='" & Me![Phase] & "'")
End Sub

--

Ken Snell
<MS ACCESS MVP>



copprtop116 said:
Long time viewer, first time participant. Love the site, it is immensely
helpful.

Situation. I inherited a database in which depending on the selection
chose
from a combo box on a form, a text box on the same form would be completed
with the desired verbiage which can be altered. The creator used an "event
procedure" on the combo box "after update" that will use a statement to
fill
in the data.
"Phase" is the combo box and "PhaseDetails" is the text box.

"After Update" vb Code:
Private Sub Phase_AfterUpdate()
If Me![Phase] = "Student 1" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of White
Milk" & vbCrLf & "1 - Afternoon Snack"
ElseIf Me![Phase] = "Student 2" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
Chocolate Milk" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
ElseIf Me![Phase] = "Student 3" Then
Me![PhaseDetails] = "1 - Alphabet Coloring Book" & vbCrLf & "2 - Pints
of Milk (choice)" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
End If
End Sub

Now by the time I get to the upper grades, the list of items becomes very
long. And the text in vb code can not be formatted or spaced properly so
the
words do not align and the text box verbiage looks sloppy.

My attempt was to use an external word doc for these long phase details.
Now
is this possible? Will the text of that imported word doc show up in the
phase details table?

Any help, ideas or suggestions would be greatly appreciated.
Thanks!
color me extremely frustrated!
 
K

Ken Snell \(MVP\)

Only way would be to change the Font of the combo box to a fixed-width font
type, such as Courier. A proportional-width font is nearly impossible to
make perfect lineups.

--

Ken Snell
<MS ACCESS MVP>


copprtop116 said:
Thanks Ken,
that is much easier.
However a small problem. When the information is added, the rows don't
always line up. I'd like to have the information align like tab settings
in
word. Sometimes they are off by half a space. Is there any way to add half
a
space?

1 - coloring book
1 - pint of milk
1 - afternoon snack

Is this possible? Is there such a thing as tab settings?
Thank you ever so much, I'll cherish my remaining hair follicles.
Lori


Ken Snell (MVP) said:
Create a table..name it tblPhaseDetails. Put two fields in it: Phase
(Text
255) and PhaseDetail (either Text 255 or Memo (if text will exceed 255
characters).

Put the phase value strings into the first field, and the longer text for
phase details in the second field; you can enter a new line (the
combination
of carriage return and line feed characters) by pressing Ctrl+Enter when
typing the data into the field. Create one record for each option that is
in
the first combobx.

Then change your code to this:

Private Sub Phase_AfterUpdate()
Me![PhaseDetails] = DLookup("PhaseDetail", "tblPhaseDetails", _
"[Phase]='" & Me![Phase] & "'")
End Sub

--

Ken Snell
<MS ACCESS MVP>



copprtop116 said:
Long time viewer, first time participant. Love the site, it is
immensely
helpful.

Situation. I inherited a database in which depending on the selection
chose
from a combo box on a form, a text box on the same form would be
completed
with the desired verbiage which can be altered. The creator used an
"event
procedure" on the combo box "after update" that will use a statement to
fill
in the data.
"Phase" is the combo box and "PhaseDetails" is the text box.

"After Update" vb Code:
Private Sub Phase_AfterUpdate()
If Me![Phase] = "Student 1" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
White
Milk" & vbCrLf & "1 - Afternoon Snack"
ElseIf Me![Phase] = "Student 2" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
Chocolate Milk" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
ElseIf Me![Phase] = "Student 3" Then
Me![PhaseDetails] = "1 - Alphabet Coloring Book" & vbCrLf & "2 -
Pints
of Milk (choice)" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 -
Lunch
Ticket"
End If
End Sub

Now by the time I get to the upper grades, the list of items becomes
very
long. And the text in vb code can not be formatted or spaced properly
so
the
words do not align and the text box verbiage looks sloppy.

My attempt was to use an external word doc for these long phase
details.
Now
is this possible? Will the text of that imported word doc show up in
the
phase details table?

Any help, ideas or suggestions would be greatly appreciated.
Thanks!
color me extremely frustrated!
 
C

copprtop116

Thank you very much!
Your knowledge is priceless and I do appreciate it! Thanks so much for
sharing.
Lori

Ken Snell (MVP) said:
Only way would be to change the Font of the combo box to a fixed-width font
type, such as Courier. A proportional-width font is nearly impossible to
make perfect lineups.

--

Ken Snell
<MS ACCESS MVP>


copprtop116 said:
Thanks Ken,
that is much easier.
However a small problem. When the information is added, the rows don't
always line up. I'd like to have the information align like tab settings
in
word. Sometimes they are off by half a space. Is there any way to add half
a
space?

1 - coloring book
1 - pint of milk
1 - afternoon snack

Is this possible? Is there such a thing as tab settings?
Thank you ever so much, I'll cherish my remaining hair follicles.
Lori


Ken Snell (MVP) said:
Create a table..name it tblPhaseDetails. Put two fields in it: Phase
(Text
255) and PhaseDetail (either Text 255 or Memo (if text will exceed 255
characters).

Put the phase value strings into the first field, and the longer text for
phase details in the second field; you can enter a new line (the
combination
of carriage return and line feed characters) by pressing Ctrl+Enter when
typing the data into the field. Create one record for each option that is
in
the first combobx.

Then change your code to this:

Private Sub Phase_AfterUpdate()
Me![PhaseDetails] = DLookup("PhaseDetail", "tblPhaseDetails", _
"[Phase]='" & Me![Phase] & "'")
End Sub

--

Ken Snell
<MS ACCESS MVP>



Long time viewer, first time participant. Love the site, it is
immensely
helpful.

Situation. I inherited a database in which depending on the selection
chose
from a combo box on a form, a text box on the same form would be
completed
with the desired verbiage which can be altered. The creator used an
"event
procedure" on the combo box "after update" that will use a statement to
fill
in the data.
"Phase" is the combo box and "PhaseDetails" is the text box.

"After Update" vb Code:
Private Sub Phase_AfterUpdate()
If Me![Phase] = "Student 1" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
White
Milk" & vbCrLf & "1 - Afternoon Snack"
ElseIf Me![Phase] = "Student 2" Then
Me![PhaseDetails] = "1 - Coloring Book" & vbCrLf & "1 - Pint of
Chocolate Milk" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 - Lunch
Ticket"
ElseIf Me![Phase] = "Student 3" Then
Me![PhaseDetails] = "1 - Alphabet Coloring Book" & vbCrLf & "2 -
Pints
of Milk (choice)" & vbCrLf & "1 - Afternoon Snack" & vbCrLf & "1 -
Lunch
Ticket"
End If
End Sub

Now by the time I get to the upper grades, the list of items becomes
very
long. And the text in vb code can not be formatted or spaced properly
so
the
words do not align and the text box verbiage looks sloppy.

My attempt was to use an external word doc for these long phase
details.
Now
is this possible? Will the text of that imported word doc show up in
the
phase details table?

Any help, ideas or suggestions would be greatly appreciated.
Thanks!
color me extremely frustrated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top