COULD SOMONE PLEASE HELP?

D

deercreek

I need some help figuring something out. I'm not sure if I heading in
the correct direction. What I'm trying to accomplish is the following.
I have a table that has id, discrip, and 2 date fields. I am populating
this information
from a sub from on a main form. The Id and date fields are tied
together in the forms. I am
trying to get the descrip field to show up in my main form under a
listbox. I have
created a sql query to try to accomplish this. I can have multiple
lines of information for each id. That's why I'm trying to show in
list box. The problem I am having is I cannot get it to look for
specific id of the current page I'm on in the form. It prompts me for
id. If I enter the id the list box displays correct info. I would like
for it to see what page I'm on in my form take the id from there and
fill the list box accordingly. When I change sheets it would
automatically update. I have pasted sql query below. I would really
appreciate any insight on how to make this work. Thanks ahead of time.



Perhaps Im not making myself clear. I want a list box to show
information from a table in a form. The table is not the table that
main form is driving. I want the list box to see the reservationid from

the form on which ever record is active, and to show only the
information where the 2 reservation id's are =. The list box will work
if I type in reservationid, but it won't get it from the active form
page like I want. Hopefully this bettrer explains problem.


SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve
WHERE (([reserve].[reservationid])=([reservations].[reservationsid]));
 
J

John Vinson

Please don't shout at us. We're all volunteers, and the only reason we
COME here is to help. You'll get much better response if you put a
brief indication of the nature of the problem in the subject line.
I need some help figuring something out. I'm not sure if I heading in
the correct direction. What I'm trying to accomplish is the following.
I have a table that has id, discrip, and 2 date fields. I am populating
this information
from a sub from on a main form. The Id and date fields are tied
together in the forms.

What are the Recordsources of the two Forms? Both the same table??
I am trying to get the descrip field to show up in my main form under a
listbox. I have
created a sql query to try to accomplish this. I can have multiple
lines of information for each id.

That would typically be done with a continuous Subform, not a listbox;
if you want to be able to edit the Descrip a subform would be
essential, since you cannot edit data in a listbox.
That's why I'm trying to show in
list box. The problem I am having is I cannot get it to look for
specific id of the current page I'm on in the form. It prompts me for
id. If I enter the id the list box displays correct info. I would like
for it to see what page I'm on in my form take the id from there and
fill the list box accordingly. When I change sheets it would
automatically update. I have pasted sql query below. I would really
appreciate any insight on how to make this work. Thanks ahead of time.

There are no "sheets" in Access. Do you mean when you move to a new
record? If you really want to use a Listbox, it would need to be based
on a query referencing the ID on the FORM (see below); and you would
need to Requery the listbox in VBA code whenever you move to a new
record.
Perhaps Im not making myself clear. I want a list box to show
information from a table in a form. The table is not the table that
main form is driving. I want the list box to see the reservationid from
the form on which ever record is active, and to show only the
information where the 2 reservation id's are =. The list box will work
if I type in reservationid, but it won't get it from the active form
page like I want. Hopefully this bettrer explains problem.


SELECT [reserve].[site], [reserve].[reservationid],
[reservations].[reservationsid]
FROM reserve
WHERE (([reserve].[reservationid])=([reservations].[reservationsid]));

CHange this last line to

WHERE (([reserve].[reservationid]) =
([Forms]![NameOfYourForm]![reservationsid]))

and put the following code in both the Form's Current event and the
AfterUpdate event of reservationsid:

Me!nameoflistbox.Requery

John W. Vinson[MVP]
 
D

deercreek

Thnaks for help I did what you suggested and I get the following ERROR.


Microsoft Access can't find the macro 'Me!Lstsites.'

The list box is now showing sites for the first record, when I change
recored I get the above error.
any other help would be apperciated.

Thanks
Dan
 
J

John Vinson

Thnaks for help I did what you suggested and I get the following ERROR.


Microsoft Access can't find the macro 'Me!Lstsites.'

The list box is now showing sites for the first record, when I change
recored I get the above error.
any other help would be apperciated.

Thanks
Dan

Rather than typing the text directly into the control's event line,
click the ... icon by the AfterUpdate event and choose "Code Builder".
Access will give you the Sub and End Sub lines free of charge; just
edit it to

Private Sub <whatever>_AfterUpdate()
Me!lstSites.Requery
End Sub


John W. Vinson[MVP]
 

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