List boxes to load records

  • Thread starter Thread starter SC
  • Start date Start date
S

SC

I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that record? I
imagine its probably pretty easy and I'm just overlooking
something...
 
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
 
Okay...the primary key is called "Child Number" and the
Listbox is called "List39". I tried the code below, and
got "Compile error: Syntax error." The middle line is
highlighted in blue, but the top line is yellow with the
arrow pointing to it. What am I doing wrong?

Private Sub List39_AfterUpdate()
DoCmd.ApplyFilter ,"[Child Number] = " & {List39}
End Sub


SC

-----Original Message-----
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
-----Original Message-----
I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that record? I
imagine its probably pretty easy and I'm just overlooking
something...



.
.
 
Try
DoCmd.ApplyFilter ,"[Child Number] = " & List39

I only put {} in to show what needs to be replaced.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----

Okay...the primary key is called "Child Number" and the
Listbox is called "List39". I tried the code below, and
got "Compile error: Syntax error." The middle line is
highlighted in blue, but the top line is yellow with the
arrow pointing to it. What am I doing wrong?

Private Sub List39_AfterUpdate()
DoCmd.ApplyFilter ,"[Child Number] = " & {List39}
End Sub


SC

-----Original Message-----
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
-----Original Message-----
I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that record? I
imagine its probably pretty easy and I'm just overlooking
something...



.
.
.
 
oops. Thanks.
Now when I click it shows in the bottom left that it is
filtered record 1 of 1, but all the number, name, last
name, address and other two fields go blank...why is
this? All the data is coming from the same query. There
is another listbox in the form with data from a different
query...it doesn't change when I click the list box in
question (List39)

SC
-----Original Message-----
Try
DoCmd.ApplyFilter ,"[Child Number] = " & List39

I only put {} in to show what needs to be replaced.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----

Okay...the primary key is called "Child Number" and the
Listbox is called "List39". I tried the code below, and
got "Compile error: Syntax error." The middle line is
highlighted in blue, but the top line is yellow with the
arrow pointing to it. What am I doing wrong?

Private Sub List39_AfterUpdate()
DoCmd.ApplyFilter ,"[Child Number] = " & {List39}
End Sub


SC

-----Original Message-----
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
-----Original Message-----
I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that record? I
imagine its probably pretty easy and I'm just overlooking
something...



.

.
.
.
 
Nothing obvious springs to mind. If you have the record
navigators visible, does pressing any of those bring the
record details onto the form?

Gerald Stanley MCSD
-----Original Message-----
oops. Thanks.
Now when I click it shows in the bottom left that it is
filtered record 1 of 1, but all the number, name, last
name, address and other two fields go blank...why is
this? All the data is coming from the same query. There
is another listbox in the form with data from a different
query...it doesn't change when I click the list box in
question (List39)

SC
-----Original Message-----
Try
DoCmd.ApplyFilter ,"[Child Number] = " & List39

I only put {} in to show what needs to be replaced.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----

Okay...the primary key is called "Child Number" and the
Listbox is called "List39". I tried the code below, and
got "Compile error: Syntax error." The middle line is
highlighted in blue, but the top line is yellow with the
arrow pointing to it. What am I doing wrong?

Private Sub List39_AfterUpdate()
DoCmd.ApplyFilter ,"[Child Number] = " & {List39}
End Sub


SC


-----Original Message-----
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update
eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
-----Original Message-----
I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want
to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is
gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that record? I
imagine its probably pretty easy and I'm just
overlooking
something...



.

.

.
.
.
 
Hm. I just recreated the form from scratch, used that
code, and the whole thing worked perfect this time...odd.
Thanks for the help!

SC

-----Original Message-----
oops. Thanks.
Now when I click it shows in the bottom left that it is
filtered record 1 of 1, but all the number, name, last
name, address and other two fields go blank...why is
this? All the data is coming from the same query. There
is another listbox in the form with data from a different
query...it doesn't change when I click the list box in
question (List39)

SC
-----Original Message-----
Try
DoCmd.ApplyFilter ,"[Child Number] = " & List39

I only put {} in to show what needs to be replaced.

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----

Okay...the primary key is called "Child Number" and the
Listbox is called "List39". I tried the code below, and
got "Compile error: Syntax error." The middle line is
highlighted in blue, but the top line is yellow with the
arrow pointing to it. What am I doing wrong?

Private Sub List39_AfterUpdate()
DoCmd.ApplyFilter ,"[Child Number] = " & {List39}
End Sub


SC


-----Original Message-----
If the Number is the primary key, you can put code along
the following lines in the list box's After_Update
eventhandler

DoCmd.ApplyFilter ,"[Number] = " & {yourlistboxname}

Hope This Helps
Gerald Stanley
-----Original Message-----
I have a form that shows Number, First Name, Last Name,
Address, and two other fields for each record. I want
to
add a list box that will display all the numbers, first
names, and last names. With access 2k, you can pick the
option of using the list box to load whatever record is
clicked on. In access 2k3, however, this option is
gone.
How can I make it so when I click a particular record
displayed in the listbox, the form loads that
record?
.
 
Back
Top