first database

K

Kevin

Hi all.

I am trying to learn Access 2002 and have run into my first question.

I have created a single table called tblSales and in it I have two fields,
fldDate and fldSales. fldDate is the primary key.

I have made a simple form with the wizard to include both and I have added
some data. (txtDate and txtSales)

What I am trying to do is if I type in a date into the text box I would like
it to look at the table. If the date exist then fill in the Sales text box
that is in that record. If the date does not exist in the table then clear
out the Sales text box to create a new record.

Thank you for your help.

Kevin
 
S

Simonc

Hi Kevin - Its a bit difficult to tell what you are trying to do, but you could
try and use a combo box - the wizard will create one for you, and ask it to look
up data on your form. You can then either type in a date or look one up in the
combo box. The combo box will list all of the dates you have in your table, and
when you select a date will show what sales go with it. Your last two sentences
are a bit confusing. What do you want to fill the sales text box with; if the
date does not exist, what are you clearing out of the sales text box?
Simon
 
S

Simonc

Yes, using a combo box would not be suitable if you are recording a new sale
each day. You need to be careful here though. Are you anticipating only one sale
per day? If not then you should use more than one table.

To find your records you could use the wizard again (on the toolbox) and put a
findfirst command button on the form. There are a number of ways to search and
it may be case of choosing which you feel more comfortable with - you can use
sql, but that is more complicated.

Remember though, that if you type in a date into a text box, you are changing
the record - you may need a separate text box to find data unless you use the
findfirst - the findfirst opens a separate prompt.

Try it and let me know how you get on.
 
K

Kevin

Hi Simon.

Let me try to explain...

Everyday of the year I will create a new record for that day with the sales
for that date. i.e. -

1/01/03 $100.00
1/02/02 $150.00
1/03/03 $125.00

If today is 1/04/03 the form should default to todays date and be a new
record. But if I want to look back to an earlier day I was thinking I would
type the date, like 1/01/3, and it would bring up that record showing
$100.00 in the sales text box. You suggested I should use a combo box. I
think I know how to do that. Would that be too much though when it is
December and I have over 300 dates in the drop down?

Thank you.
Kevin
 

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