Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control 2

Status
Not open for further replies.
Jul 30, 2004
19
US
I have a form with a Calendar Control. I want to click on a date and populate a text box (if all of the text boxes are blank I would populate the first texts box). I want to click on another date and populate the next blank text box (given the example above the next blank text box would be the second text box. Example of dates on form:
List of dates:
(1)date1
...
(12)date12
When all of the date text boxes are full, I will need a way to delete all of the dates from all of the text boxes so I can start the process over.
TIA TIA TIA
 
Hi, fullofquestions,

As an academic exercise, what you want to do is not terribly difficult. But a little warning bell is going off in my head, and I'm asking myself "why?".

My first impression is this sounds like a flat-file, non-normalized setup, which will lead to many headaches if pursued. But I don't want to jump to conclusions. Can you provide some more info? Specifically:

1) Your table or query structure
2) Is the form bound to the table or query?
3) Are the date fields bound?
4) Is the default form view single, continuous, or datasheet?

Ken S.
 
Hi Eupher

This is an extension of an existing system that contains individuals that volunteer their time and money to an organization that provides services to special needs children. The provide swimming days to the elderly. These are sold to make money for the organization. The dates represent attendance in 12 visit blocks.
I have a single table with 12 date fields
The form is bound to that table
The data fields are bound
It is a single view form.

TIA
 
I am a little confused by this:
fullofquestions said:
When all of the date text boxes are full, I will need a way to delete all of the dates from all of the text boxes so I can start the process over.
Your date fields are bound... You really want to delete all 12 dates from the current record in your table once all the date fields for a given record are filled?

Ken S.
 
Also, are your date fields going to be locked, so that dates can only be entered via the calendar control? If not, the logic for handling the date fields gets more complex.

Ken S.
 
And what if the user clicks a date accidentally and one needs to be removed?

Ken S.
 
How are ya fullofquestions . . . . .

As a starting reference, in the [blue]AfterUpdate[/blue] event of your [blue]Calendar[/blue], try the following:
Code:
[blue]   Dim x As Integer, Name As String
   
   For x = 1 To 12
      Name = "Date" & Trim(Str(x))
      
      If Trim(Me(Name) & "") = "" Then
         Me(Name) = Me![purple][b]CalendarControlName[/b][/purple]
         [b]Exit For[/b]
      End If
   Next[/blue]
. . . and to delete:
Code:
[blue]   Dim x As Integer
   
   For x = 1 To 12
      Me("Date" & Trim(Str(x))) = ""
   Next[/blue]

Calvin.gif
See Ya! . . . . . .
 
Yup, that's pretty much the direction I was headed. To expand on AceMan's solution, if you want to make the deletion of the fields automatic once all fields are full, try this:
Code:
Dim x As Integer, y As Integer, Name As String
For x = 1 To 12
    Name = "Date" & Trim(Str(x))      
    If Trim(Me(Name) & "") = "" Then
        Me(Name) = Me!CalendarControlName
        Exit For
        ElseIf (x = 12) And (Trim(Me(Name) & "") <> "") Then
        If MsgBox("All date fields full.  Must delete all date fields to continue." & vbCrLf _
            & "Okay to continue?", vbYesNo, "All Fields Full") = vbYes Then
            For y = 1 To 12
                Me("Date" & Trim(Str(y))) = ""
            Next y
            Me!Date1 = Me!CalendarControlName
        End If
    End If
Next x
HTH,

Ken S.
 
Thanks AceMan1 and Eupher. But there is a problem. The selected date populates all of the 12 date fields with the same date. Clicking on another date only changes the date in the first date field.
Let me try to do a better job of explaining what I am trying to do. Example: On Monday a guest pays for 12 days use of the pool. On Wednesday that person arrives to use the pool and I want to record their attendance...so the first date field would contain Wednesday's date. On Friday that person arrives to use the pool again and I wnat to record their attendance again...so the second date field would contain Friday's date. This process will continue until all 12 dates have been used. At that time I want the option of deleting all of the dates and starting over. I really appreciate your help as will all of the special needs children.
 
Hi, fullofquestions,

The code that AceMan and I posted depends upon the naming scheme of your date fields, i.e. Date1, Date2, Date3, etc. It should not populate all the date fields. Have you tried setting a breakpoint and stepping through the code to see what's going on?

Ken S.
 
Hi Eupher,

My sincere appologies. Even though I triple checked my work. It was my problem, a typo. I had to go away from it and then return to see it.
Again, thank you so much for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top