relationships

paulevans

Registered User.
Local time
Today, 14:26
Joined
Mar 7, 2006
Messages
79
Hi

I have created two tables which are linked with a one-to-many relationship

Using a form the user enters a date. Then in VB I add a value to the date and store this in the second table.

I have simplified this to try to find out what was going wrong and found that when the database adds a value to the second table which only has two fields it first of all adds it to the begining of the record set and the id field does not update to that of the first table where the relationship is joined.

Do I just captutre the value of the id field and add this to the recordset.
How to I get the database to look foir the end of record set before I appent the new generated record.
 
When you say you are adding a value, does this mean you are taking the date and adding x number of days to it and then storing this new date in the second table?
 
Hi Ken
Yes that is it I take the date from the first table then add x days onto it and store in the second table. This may happen a nuber of time where I just keep adding x days to the new date and I end up having y new records. These all have to be related to the id.

Thanks
 
How are you telling the system how many days you need to add to the new record?
 
Hi Ken
here is my simpe bit of code:

Private Sub datev_Change()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("table2")
Dim valdate As Date
Dim newdaten As Date
'set some calculation to show that it works
valdate = CDbl(Me.datev) 'Get date from table 1
newdaten = valdate 'set newdate to handle date changes
i = 0
Do While i < 6
rst.AddNew
rst![newdate] = newdaten
rst.Update
newdaten = newdaten + 10 'update value of date
i = i + 1
Loop
Set rst = Nothing
Set db = Nothing
End Sub


Hope this helps
 

Users who are viewing this thread

Back
Top Bottom