To be honest, I am not sure if this should go into the VBA section, but let my try to explain my problem.
Let us say that I have a simple database with two tables (example DB is uploaded here: http://vinther-jensen.dk/access/test.mdb) .
One table holds types of expenses (tblUdgiftstyper) while the other holds some values. Each value is paired with an expensetype.
Along with the value two dates are written to the table; the date/time at which it is entered (DataSat), and the date/time at which the values are no longer relevant (DatoUdloeb).
I have made a simple form, which I intent to use for data input/editing (frmAddValues). I will properbly show this as a datasheet.
When opening the form all expensetypes from tblUdgiftstyper must be loaded to the form, so that the user can enter data for each of them.
I have tried doing this via VBA.
But this is causing my some trouble.
I have tried using two different queries to load the data:
and then use this as the forms RecordSource. But when I afterwards loop through the fields from the form I only get the first column.
I have then tried
Which gives me all expensetypes and loads zeroes as values, but it will not let me edit the data once they are loaded.
What am I doing wrong?
I should mention, that I intent to usethe same form to allow the user to edit data. My idea is to the change the query to let it load the actual data, which can then be edited.
I should also mention, that in the real project I need to update some other values and change the expiration date of the existing values prior to writing the new/edited data.
Let us say that I have a simple database with two tables (example DB is uploaded here: http://vinther-jensen.dk/access/test.mdb) .
One table holds types of expenses (tblUdgiftstyper) while the other holds some values. Each value is paired with an expensetype.
Along with the value two dates are written to the table; the date/time at which it is entered (DataSat), and the date/time at which the values are no longer relevant (DatoUdloeb).
I have made a simple form, which I intent to use for data input/editing (frmAddValues). I will properbly show this as a datasheet.
When opening the form all expensetypes from tblUdgiftstyper must be loaded to the form, so that the user can enter data for each of them.
I have tried doing this via VBA.
But this is causing my some trouble.
I have tried using two different queries to load the data:
Code:
SELECT tblUdgiftsstyper.Udgiftsstype
FROM tblUdgiftsstyper;
and then use this as the forms RecordSource. But when I afterwards loop through the fields from the form I only get the first column.
I have then tried
Code:
TRANSFORM '0' AS Udtryk2
SELECT tblUdgiftsstyper.Udgiftsstype
FROM tblUdgiftsstyper
GROUP BY tblUdgiftsstyper.Udgiftsstype
PIVOT Year in ('2010','2011','2012','2013');
Which gives me all expensetypes and loads zeroes as values, but it will not let me edit the data once they are loaded.
What am I doing wrong?
I should mention, that I intent to usethe same form to allow the user to edit data. My idea is to the change the query to let it load the actual data, which can then be edited.
I should also mention, that in the real project I need to update some other values and change the expiration date of the existing values prior to writing the new/edited data.