Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / January 2005

Tip: Looking for answers? Try searching our database.

Dynamic "path" to a control in an access db?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
code - 04 Jan 2005 06:39 GMT
Hello, I created a little form to serve as a custom date picker popup, and I
wanted to make it generic enough to be used in several places in my database.
It works well, but you have to feed it the current master/detail form names
as well as the control name which needs the picked value, and then those
values are temporarily stored in hidden fields in the popup form.

I would like to make the call to the popup function more generic, too, so
that it could be called the same way every time. I'm currently calling that
function like this:

Private Sub cmdPick1_Click()
   Me.TheDate1.SetFocus
   PickerLaunch Form.Name, Me.TheDate1.Name, Me.TheDate1.Text, "tblMaster"
End Sub

And I think it would be better to use something like this:

Private Sub cmdPick1_Click()
   Me.TheDate1.SetFocus
   PickerLaunch getPath("txtDate1")
End Sub

Private Function getPath(strControlName) as String
  ' Code that returns a value something like this:
  ' Forms("MasterFormName").Form.Controls("ChildFormName").Form("txtDate1")
End Function

Can this be done? I could use it elsewhere, too!
M.L. Sco Scofield - 04 Jan 2005 08:35 GMT
Here's what I use. Some of it was "leveraged" :-) from somewhere and then
modified. This has been in one of my production apps for over 9 years.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code in calendar popup form:

Private Sub cmdClose_Click()
   DoCmd.Close
End Sub

Private Sub cmdOK_Click()
   Me.Visible = False
End Sub

Private Sub Form_Load()

 If IsNull(Me.OpenArgs) = False Then
   Me!axCalendar = Me.OpenArgs
 Else
   Me!axCalendar = Date
 End If

End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code for command buttons:

Private Sub cmdEndDate_Click()

 DateCheck txtEndDate

 txtEndDate.SetFocus

End Sub

Private Sub cmdStartDate_Click()

 DateCheck txtStartDate

 txtStartDate.SetFocus

End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code in a standalone module:

Public Sub DateCheck(ctlDate As TextBox)

 Dim varDatePassed As Variant
 Dim varReturn As Variant

 varDatePassed = ctlDate

 varReturn = GetDate(varDatePassed)

 If IsNull(varReturn) = False Then
   ctlDate = varReturn
 End If

End Sub

Private Function GetDate(Optional varDate As Variant) As Variant

   ' If varTempDate is missing then use today's date.
   ' Otherwise, set the date to the date passed.

   Dim varTempDate As Variant

   ' Set calendar date
   varTempDate = IIf(IsMissing(varDate), Date, varDate)

   ' Validate date
   If Not IsDate(varTempDate) Then varTempDate = Date
   DoCmd.OpenForm FormName:="fdlgCalendarControl", WindowMode:=acDialog,
OpenArgs:=varTempDate

   ' If fdlgCalendarControl is still loaded, then the user clicked OK so
get the
   ' date from the form.  If the form isn't open return a value of Null.
   If IsFormLoaded("fdlgCalendarControl") Then
       GetDate = Forms("fdlgCalendarControl").axCalendar.Value
       DoCmd.Close acForm, "fdlgCalendarControl"
   Else
       GetDate = Null
   End If

End Function

Private Function IsFormLoaded(ByVal strformName As String) As Boolean

 Const conObjStateClosed = 0
 Const conDesignView = 0

 If SysCmd(acSysCmdGetObjectState, acForm, strformName) <>
conObjStateClosed Then
   If Forms(strformName).CurrentView <> conDesignView Then
     IsFormLoaded = True
   End If
 End If

End Function

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enjoy and good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com

> Hello, I created a little form to serve as a custom date picker popup, and I
> wanted to make it generic enough to be used in several places in my database.
[quoted text clipped - 21 lines]
>    ' Code that returns a value something like this:
>    '
Forms("MasterFormName").Form.Controls("ChildFormName").Form("txtDate1")
> End Function
>
> Can this be done? I could use it elsewhere, too!
code - 04 Jan 2005 15:35 GMT
Hello, Yes! That is what I was looking for. Very nice and clean, all fully
typed, excellent work! I will probably also use varations of this for years!

Thank you very much!

--Jon

> Here's what I use. Some of it was "leveraged" :-) from somewhere and then
> modified. This has been in one of my production apps for over 9 years.
[quoted text clipped - 143 lines]
> >
> > Can this be done? I could use it elsewhere, too!
M.L. Sco Scofield - 04 Jan 2005 22:52 GMT
You're most welcome.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com

> Hello, Yes! That is what I was looking for. Very nice and clean, all fully
> typed, excellent work! I will probably also use varations of this for years!
[quoted text clipped - 150 lines]
> > >
> > > Can this be done? I could use it elsewhere, too!
Alex Dybenko - 04 Jan 2005 08:49 GMT
You can also look at my solution here:
http://www.pointltd.com/Downloads/Details.asp?dlID=32

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Hello, I created a little form to serve as a custom date picker popup, and
> I
[quoted text clipped - 29 lines]
>
> Can this be done? I could use it elsewhere, too!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.