Combo List

D

Double A

I have set up a 2 column combo box for my form. I use it to choose from a
list of steps so that I can populate my table with only the ones I want. Is
there a way to have the list open each time to the spot in the list where I
left off?
 
J

Jeanette Cunningham

Double A,
you could save the value chosen in the combo to a new table.
Create a table to hold the value.
In the after update event of the form put code something like:

Dim strSQL as String
Dim db As DAO.Database

strSQL = "Update TableName " _
"Set TableName.TheField = Me.NameOfCombo

If Not IsNull(Me.NameOfCombo) Then
db.Execute strSQL, dbFailOnError
End If
Set db = Nothing


Put code in the form's load event to lookup the value from the table and set
the combo to this value.

Something like (assuming combo's 1st column is number data type)
Dim lngTheValue as Long
lngTheValue = Nz(DLookup("[TheField]", "TableName"), 0)
If lngTheValue >0 Then
Me.NameOfCombo = lngtheValue
Else
End If

Jeanette Cunningham -- Melbourne Victoria Australia
 
D

Double A

Thank you so much for the code. Regarding the second part (load event), the
combo's first column is not a number data type.

Within the same record, the combo box opens to where it left off if a value
was entered in that record. However when going to the next record, to enter
another step in the list, this is where I would like the combo box to open
where it left off in the previous record.

Any thoughts?
thanks.

Jeanette Cunningham said:
Double A,
you could save the value chosen in the combo to a new table.
Create a table to hold the value.
In the after update event of the form put code something like:

Dim strSQL as String
Dim db As DAO.Database

strSQL = "Update TableName " _
"Set TableName.TheField = Me.NameOfCombo

If Not IsNull(Me.NameOfCombo) Then
db.Execute strSQL, dbFailOnError
End If
Set db = Nothing


Put code in the form's load event to lookup the value from the table and set
the combo to this value.

Something like (assuming combo's 1st column is number data type)
Dim lngTheValue as Long
lngTheValue = Nz(DLookup("[TheField]", "TableName"), 0)
If lngTheValue >0 Then
Me.NameOfCombo = lngtheValue
Else
End If

Jeanette Cunningham -- Melbourne Victoria Australia

Double A said:
I have set up a 2 column combo box for my form. I use it to choose from a
list of steps so that I can populate my table with only the ones I want.
Is
there a way to have the list open each time to the spot in the list where
I
left off?
 
J

Jeanette Cunningham

Double A,
the table that stores the last used step needs to have a second field to
store the record nmber associated with each step.
The table will need to store both the record number and the step.
You will need to write an append query to append the record number and the
step when you start a new record.
Use an update query to update that record when you move to a new step for
the same record number.
I haven't covered the situation if you go back in time and edit an earlier
step, that is something to think about.

When the form opens, the code in the load event needs to look for the step
where the record number matches the record number of the form.
You add a criteria to the DLookup expression.


Jeanette Cunningham -- Melbourne Victoria Australia


Double A said:
Thank you so much for the code. Regarding the second part (load event),
the
combo's first column is not a number data type.

Within the same record, the combo box opens to where it left off if a
value
was entered in that record. However when going to the next record, to
enter
another step in the list, this is where I would like the combo box to open
where it left off in the previous record.

Any thoughts?
thanks.

Jeanette Cunningham said:
Double A,
you could save the value chosen in the combo to a new table.
Create a table to hold the value.
In the after update event of the form put code something like:

Dim strSQL as String
Dim db As DAO.Database

strSQL = "Update TableName " _
"Set TableName.TheField = Me.NameOfCombo

If Not IsNull(Me.NameOfCombo) Then
db.Execute strSQL, dbFailOnError
End If
Set db = Nothing


Put code in the form's load event to lookup the value from the table and
set
the combo to this value.

Something like (assuming combo's 1st column is number data type)
Dim lngTheValue as Long
lngTheValue = Nz(DLookup("[TheField]", "TableName"), 0)
If lngTheValue >0 Then
Me.NameOfCombo = lngtheValue
Else
End If

Jeanette Cunningham -- Melbourne Victoria Australia

Double A said:
I have set up a 2 column combo box for my form. I use it to choose from
a
list of steps so that I can populate my table with only the ones I
want.
Is
there a way to have the list open each time to the spot in the list
where
I
left off?
 
Top