Double Search Table

Directlinq

Registered User.
Local time
Today, 02:48
Joined
Sep 13, 2009
Messages
67
Hi could someone please help me?

I have a table With 4 fields
Id,Month,Year,Total

1,jan,2009,51
2,feb,2009,44
3,mar,2010,77

On my form i have 3 fields
Month,Year,Total

Is it possible when i press a button on my form it will search the table for the same combination of Month & Year.

E.g on my table i have jan 2009 88, It will then search the table for a january with the date 2009 if found overwrite the new total if not found add all 3 fields to the table.
So there will only ever be 1 of jan,2009 or feb,2009 or feb,2010 etc.

Hope you can help
Many Thanks
 
answer depends on how you are indicating or selecting the month and year on your form. are you using comboboxes?
 
The Year is in a hidden textbox and the month is in a hidden combobox. Both get there values from a public variable.
 
you could create a query with all of the fields. in the criteria for the year enter
Forms!yourformname!textboxname
for the month enter
Forms!yourformname!combobox name

you can then lookup the id of the query. if you get a result then you know that a record exists, otherwise enter a new record.

test the query first, with the form open, so you know it's 'reading' the form properly.

i know that's a rough outline but hopefully it will get you going. you could do it without the query if you wanted to.
 
I have created the query and it shows me if the record exsists. But im sorry but im stuck with the

you can then lookup the id of the query. if you get a result then you know that a record exists, otherwise enter a new record.

I dont know the vba code to accomplish this.

Many Thanks
 

Users who are viewing this thread

Back
Top Bottom