Hi..
I really need some help with my desperate vba skills!. When I click a date on the calendar control on my form a new record is added to the database, this works great. Trouble I have is when I click a date I have already entered I am trying to get the database to retrieve the record and display it on my form by searching through my calendar table. The code I have is below. with comments where i'm loosing it!... the sql select is the fields i need to display on my form but unsure how to link them together.. I've uploaded the db at as it was too large to upload here... http://rapidshare.com/files/221951336/drive_schedule.mdb.html
can anyone help?... Many thanks
I really need some help with my desperate vba skills!. When I click a date on the calendar control on my form a new record is added to the database, this works great. Trouble I have is when I click a date I have already entered I am trying to get the database to retrieve the record and display it on my form by searching through my calendar table. The code I have is below. with comments where i'm loosing it!... the sql select is the fields i need to display on my form but unsure how to link them together.. I've uploaded the db at as it was too large to upload here... http://rapidshare.com/files/221951336/drive_schedule.mdb.html
can anyone help?... Many thanks
Code:
Dim rs As DAO.Recordset
Dim sql As String
sql = "SELECT [Job Spec].Branch, [Job Spec].[Deliver Time], [Job Spec].[Job Type], [Job Spec].[Company Name], [Job Spec].[Site Location], [Job Spec].Equipment, [Job Spec].[Purchase Goods], [Job Spec].Driver FROM Calendar INNER JOIN [Job Spec] ON Calendar.ID = [Job Spec].ID WHERE (((Calendar.[Job Date])= " & Me![JD] & "));"
Set rs = CurrentDb.OpenRecordset("Calendar", dbOpenDynaset)
If rs.BOF And rs.EOF Then
rs.AddNew
rs![Job Date] = [Forms]![Main]![JD]
rs![NextBusinessDay] = [Forms]![Main]![NBD]
rs.Update
Me.Requery
Me.Refresh
Else
rs.MoveFirst
Do While Not rs.EOF
If rs![Job Date] = [Forms]![Main]![JD] Then
CurrentDb.OpenRecordset(sql, dbOpenDynaset) '*** Open the sql select fields on my form called main How????***
Me.Refresh
Else
rs.MoveNext
End If
Loop
rs.AddNew
rs![Job Date] = [Forms]![Main]![JD]
rs![NextBusinessDay] = [Forms]![Main]![NBD]
rs.Update
Me.Requery
Me.Refresh
End If
Last edited: