Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2007, 11:40 AM
Authorized User
 
Join Date: Apr 2007
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date issue...

Ok, here's what I currently have:

Table that has fields which have 'date/time' as their property. This is for approximately 15 locations. I have a form that I created with these 'date' fields on it which have a command button next to it labeled "insert date". When the user clicks this, it opens another form with an ActiveX Calendar Control on it. They select the desired date, click 'insert'.

This is what I'm trying to do:

When the user clicks 'insert' on the frmCalendar, I need that date in dd-mm-yyyy format to populate ONLY the field on parent form that they clicked on the 'insert date' command button.

IE: To CSM (blank date) [command button - insert date] , frmCalendar opens, user selects date, clicks 'insert' , date selected populates ONLY 'To CSM' field and no others.

Did I explain it right? Please help...

 
Old April 21st, 2007, 05:37 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Graffix,
create a global variable. When they click the button, load the variable with some value that corresponds to the particular date field you want to update. After they click 'insert', check the value of the global variable then update the corresponding date.

HTH,

Kevin

dartcoach
 
Old April 22nd, 2007, 11:03 AM
Authorized User
 
Join Date: Apr 2007
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, that'll probably work or at least sounds like it'll work. Any ideas on how to create your idea? I am starting all over again on Access so I'm kinda clueless, yet again!!

 
Old April 22nd, 2007, 06:48 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Graffix,
Create a new module, and put this line in it:
Public DteControl as integer

Then save it.

Then behind each button on your main form that calls the calendar form, add a line of code before you open the form:

DteControl = 1 (This would be the way I'd do it. 1 for the first one, 2 for the second, etc)

After you've done that, behind the insert button on your calendar form, put this:

Select Case DteControl
   Case 1
        forms![MainForm].Date1 = me.calendar0
   case 2
        Forms![MainForm].Date2 = me.calendar0
   etc.

   end select

This should work.

HTH,

Kevin

dartcoach
 
Old April 22nd, 2007, 09:49 PM
Authorized User
 
Join Date: Apr 2007
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, going to do that when I get to work in the morning. It's irritating me that I can't get this thing up and running yet, expecting a little bonus from my boss for it too!

 
Old April 22nd, 2007, 10:20 PM
Authorized User
 
Join Date: Apr 2007
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oopss...I just realized I didn't ask this question.

Given your example above for the global variable, if I have dates that say like this:

To_CSM_Assistant
From_CSM_Assistant
To_CSM
From_CSM
etc, etc...
**this goes on for about 12-18 date fields.

How do I specify when the 'insert date' command button is pressed next to the specific date requested, the date inserted populates that field? This is because not all things will need to go to each individual and some date fields may never get populated.

Thanks,

Bryan

 
Old April 23rd, 2007, 08:33 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Bryan,
Where is your 'insert date' command button?

Kevin


dartcoach
 
Old April 23rd, 2007, 08:51 AM
Authorized User
 
Join Date: Apr 2007
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is on a form, next to a text box that says "To_CSM", "From_CSM". There is an 'insert date' command button that opens the 'frmCalendar' which is an ActiveX control. Then on the 'frmCalendar', there is a command button that says 'insert date' which is supposed to pull the selected date back into the 'frmTask' in the respective 'date' text box.

I wish we could upload attachments here cause that would make it so much easier.

 
Old April 23rd, 2007, 08:56 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Bryan,

Is frmCalendar and actual form, or is it just an activeX control?

Kevin

dartcoach
 
Old April 23rd, 2007, 08:57 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Bryan,

Be careful when working with global vars like this, it can be difficult to remember rules across modules, as well as one slip-up could cause problems (I am not knocking dartcoach's kind suggestions, this is IMO).

I personally would encapsulate it all into the "frmCalendar" form like so...
Code:
'In the Calling form's "Pick Date" button (the one that has a field that requires populating)
Private Sub ADateFieldPickDate()
    PopulateWithDate TargetTextBox
End Sub

'You can put this into a Global Module if you wish....

Private Sub PopulateWithDate (ByRef TargetTextBox as TextBox)

'Populates the given TextBox control with a date via frmCalendar.
'This procedure will open the frmCalendar until its internal trigger is fired.
'DoEvents will yield processing time to the OS to stop app from hogging resources.

    Dim calFrm as New frmCalendar
    With calFrm
        Do Until .InsertPressed
            DoEvents
        Loop

        TargetTextBox.Value = .DateValue
    End With
End Function

'And in the frmCalendar....

Private m_InsPressed as Boolean
Private m_DateVal as Date

Property Get InsertPressed() As Boolean
    InsertPressed = m_InsPressed
End Property

Property Get DateValue() As Date
    DateValue = m_DateVal
End Property

Private Sub Form_Load()
    m_InsPressed = False
    m_DateVal = Null
End Sub

Private Sub cmdInsert_Click()
'Set the Form Variable "DateValue"
    m_DateVal = TheDateValue 'Replace this with however you have calculated/set your date.
    m_InsPressed = True  'Set the InsertPressed flag, this will cause the form to close in the Callers Proc.
End Sub
This will provide a much cleaner, logical movement, and it is entirely decoupled from your form code, so you can dump it in any other work you do.

I typed this code straight up, so there may be minor errors in there, if you get any probs then give me a shout and I'll be happy to help.

Regards,
Rob





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Related Issue Kirti.darji Visual Studio 2005 0 May 13th, 2008 06:40 AM
Date Issue tna55 ASP.NET 2.0 Basics 4 September 5th, 2007 04:08 AM
Date conversion Issue dhay1999 Access 2 May 30th, 2007 06:47 AM
Date function issue Grafixx01 Access 2 April 11th, 2007 02:32 PM
Date issue, using BETWEEN tdaustin Classic ASP Basics 2 June 8th, 2004 08:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.