Multi date entry

mcro7725

New member
Local time
Today, 14:31
Joined
Jun 14, 2016
Messages
5
This is probably been asked before but I cannot find any threads, probably asking the wrong question.
I have attached 3 pics in jpeg format, zipped as per newbie instructions,
The first is a basic form where I enter a task
The second is the result in the table
The third is what I want it to do without having to make 5 entries.
In other words i need to add a "from to date" on the form which creates 5 entries on the table for the 5 dates but could be more or less. I expect most of you can do this with your eyes closed and it is something so simple that i am looking right passed the answer.
Please be gentle with me I'm still a newbie at this, thanks in advance
 

Attachments

Have you considered

StartDate
Duration or NumberOfDays

why do you need a record for each day?

Just curious, I'm just trying to find out what you are trying to do.
 
Hope this helps, or gives you a better idea. This is what I found looking around, I am unable to post links at this time, but hopefully this get you going in the right direction.

Create a subform, with your BookingDetails2, set it to continuous form.

Then make a new form and add that to it, also add StartDate and another textbox (numeric value) txtNoDays then add a Go button, and add the script below.

(I cant post pics so makeshift layout)



Week Starting: |StartDate| Number of Days |txtNoDays| |Go|



you will need a script

VBA Code
Code:
 Private Sub cmdGo_Click()
Dim rs As DAO.Recordset
Dim sSQL As String
Dim sSDate As String
Dim sEDate As String

    sSDate = "#" & Format(Me.txtStartDate, "yyyy/mm/dd") & "#"
    sEDate = "#" & Format(Me.txtStartDate + Me.txtNoDays, "yyyy/mm/dd") & "#"

    sSQL = "SELECT * FROM MyTable WHERE DataDate Between " & sSDate _
        & " AND " & sEDate

    Set rs = CurrentDb.OpenRecordset(sSQL)

    If rs.RecordCount < Me.txtNoDays Then
        AddRecords sSDate, sEDate
    End If

    Me.DataSubform.Form.RecordSource = sSQL
End Sub



Sub AddRecords(sSDate, sEDate)
''Uses counter table with integers from 0 to
''highest required number
''Another useful table is a calendar table, which would
''save some work here.

    sSQL = "INSERT INTO MyTable (DataDate) " _
        & "SELECT AddDate FROM " _
        & "(SELECT " & sSDate _
        & " + [counter.ID] AS AddDate " _
        & "FROM [Counter] " _
        & "WHERE " & sSDate _
        & "+ [counter.ID] Between " & sSDate _
        & " And " & sEDate & ") a " _
        & "WHERE AddDate NOT In (SELECT DataDate FROM MyTable)"

    CurrentDb.Execute sSQL, dbFailOnError
End Sub
 
I used Mrs Smith as an example sorry probably wrong person to use. we do a number of trips from different organisations daily which need to be entered into the table as I have already created queries to show jobs for each day, another query for drivers etc etc. A report is then produced either for daily trips or trips per driver from the queries. Many bookings are daily for 39 or so weeks of the year so would be boring typing the same job 195 times. Hope that makes more sense
 

Users who are viewing this thread

Back
Top Bottom