Position form near control that called it

Howdy:
I would like to position a form (a calendar) near the control that issued a 
call to open the calendar form.  So, wherever on my calling form there is a 
control that requires a date, the calendar form will open just beneath that 
control.  Is this a job for MoveSize?  Any examples around to show the way?  
I look forward to your input.
Thanks,
Barry
0
Utf
1/20/2010 4:24:01 AM
access.formscoding 7493 articles. 0 followers. Follow

8 Replies
922 Views

Similar Articles

[PageSpeed] 57

"Barry" <Barry@discussions.microsoft.com> wrote in message 
news:B23F347F-C87D-4636-9237-5D101E7B629D@microsoft.com...
> Howdy:
> I would like to position a form (a calendar) near the control that issued 
> a
> call to open the calendar form.  So, wherever on my calling form there is 
> a
> control that requires a date, the calendar form will open just beneath 
> that
> control.  Is this a job for MoveSize?  Any examples around to show the 
> way?
> I look forward to your input.
> Thanks,
> Barry

There's more to this than you might imagine. Here's what I use:

http://www.smccall.demon.co.uk/Forms.htm#OpenUnder

HTH


0
Stuart
1/20/2010 6:03:35 AM
Stuart:
Thanks.  that certainly is more than I had bargained for.  I was hoping that 
there was a method I might actually understand.  This will give me something 
to chew on for a while.  Is there no other way to find the position of a 
control using the Access form's Left, Top and Down in relation to the Access 
window?
Thanks again,
Barry

"Stuart McCall" wrote:

> "Barry" <Barry@discussions.microsoft.com> wrote in message 
> news:B23F347F-C87D-4636-9237-5D101E7B629D@microsoft.com...
> > Howdy:
> > I would like to position a form (a calendar) near the control that issued 
> > a
> > call to open the calendar form.  So, wherever on my calling form there is 
> > a
> > control that requires a date, the calendar form will open just beneath 
> > that
> > control.  Is this a job for MoveSize?  Any examples around to show the 
> > way?
> > I look forward to your input.
> > Thanks,
> > Barry
> 
> There's more to this than you might imagine. Here's what I use:
> 
> http://www.smccall.demon.co.uk/Forms.htm#OpenUnder
> 
> HTH
> 
> 
> .
> 
0
Utf
1/20/2010 2:31:02 PM
"Barry" <Barry@discussions.microsoft.com> wrote in message 
news:B23F347F-C87D-4636-9237-5D101E7B629D@microsoft.com...
> Howdy:
> I would like to position a form (a calendar) near the control that issued 
> a
> call to open the calendar form.  So, wherever on my calling form there is 
> a
> control that requires a date, the calendar form will open just beneath 
> that
> control.  Is this a job for MoveSize?  Any examples around to show the 
> way?
> I look forward to your input.


Some time ago, I worked this out for a newsgroup post:

'------ start of code ------

    Dim strFormToOpen As String
    Dim ctlTarget As Access.Control
    Dim lngBorderHoriz As Long
    Dim lngBorderVert As Long

    strFormToOpen = "SomeFormName"

    Set ctlTarget = Me.ActiveControl

    DoCmd.OpenForm strFormToOpen

    lngBorderHoriz = (Me.WindowWidth - Me.InsideWidth) / 2
    lngBorderVert = (Me.WindowHeight - Me.InsideHeight) / 2

    With Forms(strFormToOpen)
        .Move _
            (Me.WindowLeft - .WindowWidth) + lngBorderHoriz + 
ctlTarget.Left, _
            Me.WindowTop + lngBorderVert + ctlTarget.Top
    End With
'------ end of code ------

In the above case, I opened the form to the left of the calling control, but 
it should be straightforward to modify the code to get other relative 
positions.

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
1/20/2010 6:57:57 PM
"Barry" <Barry@discussions.microsoft.com> wrote in message 
news:EF334D89-B801-4D9E-A465-8EEBEFC07CA7@microsoft.com...
> Stuart:
> Thanks.  that certainly is more than I had bargained for.  I was hoping 
> that
> there was a method I might actually understand.  This will give me 
> something
> to chew on for a while.  Is there no other way to find the position of a
> control using the Access form's Left, Top and Down in relation to the 
> Access
> window?
> Thanks again,
> Barry
<snip>

The way Access forms are constructed and their built-in behaviour makes this 
more of a task than we'd like. Fortunately you don't need to understand the 
code in order to use it. Just follow the easy instructions in the 
DropDownForm procedure.


0
Stuart
1/20/2010 6:59:52 PM
Dirk:
Thanks so much for your help.  At least this is something that I can wrap my 
head around.  I will give it a try in my app as soon as I have a moment.  
Thanks again.
Barry

"Dirk Goldgar" wrote:

> "Barry" <Barry@discussions.microsoft.com> wrote in message 
> news:B23F347F-C87D-4636-9237-5D101E7B629D@microsoft.com...
> > Howdy:
> > I would like to position a form (a calendar) near the control that issued 
> > a
> > call to open the calendar form.  So, wherever on my calling form there is 
> > a
> > control that requires a date, the calendar form will open just beneath 
> > that
> > control.  Is this a job for MoveSize?  Any examples around to show the 
> > way?
> > I look forward to your input.
> 
> 
> Some time ago, I worked this out for a newsgroup post:
> 
> '------ start of code ------
> 
>     Dim strFormToOpen As String
>     Dim ctlTarget As Access.Control
>     Dim lngBorderHoriz As Long
>     Dim lngBorderVert As Long
> 
>     strFormToOpen = "SomeFormName"
> 
>     Set ctlTarget = Me.ActiveControl
> 
>     DoCmd.OpenForm strFormToOpen
> 
>     lngBorderHoriz = (Me.WindowWidth - Me.InsideWidth) / 2
>     lngBorderVert = (Me.WindowHeight - Me.InsideHeight) / 2
> 
>     With Forms(strFormToOpen)
>         .Move _
>             (Me.WindowLeft - .WindowWidth) + lngBorderHoriz + 
> ctlTarget.Left, _
>             Me.WindowTop + lngBorderVert + ctlTarget.Top
>     End With
> '------ end of code ------
> 
> In the above case, I opened the form to the left of the calling control, but 
> it should be straightforward to modify the code to get other relative 
> positions.
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
1/20/2010 7:10:13 PM
I haven't used it in awhile, but I believe Allen Brown's form based calendar
does exactly that:

http://allenbrowne.com/ser-51.html

-- 
Message posted via http://www.accessmonster.com

0
Linq
1/20/2010 11:01:17 PM
Dirk Goldgar wrote:
>
>In the above case, I opened the form to the left of the calling control, but 
>it should be straightforward to modify the code to get other relative 
>positions.
>

Good example Dirk.
This is much simpler than using APIs like I've found in most other examples.

Thanks

I need this to open a popup form to the right of the command button so I
created this variation.
works by calling it as a sub procedure with parameters
and uses more variables for position to get the relative position to the
right of the control


'------ start of code ------

' sCForm is the Calling Form Name
' sCCtrl is the Calling Control Name
' strFormToOpen is the Name of the Form to Open
'
Sub SetFormPosition(sCForm As String, sCCtrl As String, strFormToOpen As
String)
   Dim ctlTarget As Access.Control
   Dim lngBorderHoriz As Long
   Dim lngBorderVert As Long
   Dim lngCmdWidth As Long
   Dim lngCmdHt As Long
   Dim lngCmdTop As Long
   Dim lngFrmHt As Long
   Dim lngLeftBuffer As Long
  
   Set ctlTarget = Forms(sCForm).Controls(sCCtrl)

   DoCmd.OpenForm strFormToOpen
   With Forms(sCForm)
    lngBorderHoriz = (.WindowWidth - .InsideWidth) / 5  ' adjust value for
position as needed
    lngBorderVert = (.WindowHeight - .InsideHeight) / 2
    
    lngCmdWidth = ctlTarget.Left + ctlTarget.Width
    lngCmdHt = ctlTarget.Height
    lngCmdTop = ctlTarget.Top
    lngFrmHt = Forms(strFormToOpen).WindowHeight
    
    ' Buffer value for space from right of control to left of popup form
    lngLeftBuffer = 100
    
    nWinLeftPos = .WindowLeft + lngBorderHoriz + lngCmdWidth + lngLeftBuffer
    nWinTopPos = .WindowTop + lngBorderVert + lngCmdTop + lngCmdHt - lngFrmHt
    
   End With
    
   ' Moves the form position
   Forms(strFormToOpen).Move nWinLeftPos, nWinTopPos
   
End Sub

'------ end of code ------

0
Bill
1/23/2010 2:42:11 AM
"Bill" <u57701@uwe> wrote in message news:a284fdeb305cd@uwe...
> Dirk Goldgar wrote:
>>
>>In the above case, I opened the form to the left of the calling control, 
>>but
>>it should be straightforward to modify the code to get other relative
>>positions.
>>
>
> Good example Dirk.
> This is much simpler than using APIs like I've found in most other 
> examples.
>
> Thanks
>
> I need this to open a popup form to the right of the command button so I
> created this variation.
> works by calling it as a sub procedure with parameters
> and uses more variables for position to get the relative position to the
> right of the control
>
>
> '------ start of code ------
>
> ' sCForm is the Calling Form Name
> ' sCCtrl is the Calling Control Name
> ' strFormToOpen is the Name of the Form to Open
> '
> Sub SetFormPosition(sCForm As String, sCCtrl As String, strFormToOpen As
> String)
>   Dim ctlTarget As Access.Control
>   Dim lngBorderHoriz As Long
>   Dim lngBorderVert As Long
>   Dim lngCmdWidth As Long
>   Dim lngCmdHt As Long
>   Dim lngCmdTop As Long
>   Dim lngFrmHt As Long
>   Dim lngLeftBuffer As Long
>
>   Set ctlTarget = Forms(sCForm).Controls(sCCtrl)
>
>   DoCmd.OpenForm strFormToOpen
>   With Forms(sCForm)
>    lngBorderHoriz = (.WindowWidth - .InsideWidth) / 5  ' adjust value for
> position as needed
>    lngBorderVert = (.WindowHeight - .InsideHeight) / 2
>
>    lngCmdWidth = ctlTarget.Left + ctlTarget.Width
>    lngCmdHt = ctlTarget.Height
>    lngCmdTop = ctlTarget.Top
>    lngFrmHt = Forms(strFormToOpen).WindowHeight
>
>    ' Buffer value for space from right of control to left of popup form
>    lngLeftBuffer = 100
>
>    nWinLeftPos = .WindowLeft + lngBorderHoriz + lngCmdWidth + 
> lngLeftBuffer
>    nWinTopPos = .WindowTop + lngBorderVert + lngCmdTop + lngCmdHt - 
> lngFrmHt
>
>   End With
>
>   ' Moves the form position
>   Forms(strFormToOpen).Move nWinLeftPos, nWinTopPos
>
> End Sub
>
> '------ end of code ------
>

That code will work for a form set up in a particular way, not the general 
case though. If that's sufficient for your needs then fair enough. However: 
Try switching on the main form's header. Try it with and without a record 
selector on the main form. Try it with the control to be opened under close 
to the right or bottom of the screen. Also try with the main form control on 
a tab page. Those are just the things that spring to mind - I wrote my 
module quite some time ago so I'm a bit vague on all the pros and cons, but 
you will meet them, guaranteed.


0
Stuart
1/23/2010 3:07:31 AM
Reply:

Similar Artilces:

Where can I get a free Inventory control spreadsheet
I am looking for a Inventory/Stock control excel template, but I don' want to pay for it!!!!!! Can anyone suggest a sit -- Message posted from http://www.ExcelForum.com You can search in Google, using keywords like Excel and Inventory. Or look at the templates on the Microsoft web site: http://office.microsoft.com/templates/default.aspx Pritch14 < wrote: > I am looking for a Inventory/Stock control excel template, but I don't > want to pay for it!!!!!! > > Can anyone suggest a site -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/...

GotoRecord in mainform after closing Add form
Hi, I have a form to add a new DVD to my database. Now when I press the 'ADD DVD' button I want to close the 'add dvd form' form and on the main form I want to change the current record to the one just added. The main form is open all the time. Anyone know how to jump to this added record? I tried serveral ways on the GotoRecord method of VBA but nothing worked so far. From what you are describing, the main form is tied to the list of DVDs. Why have two other forms at all? If you have nav buttons or record selectors on the main form, then just add a new record there. I...

Forms in two differant views
Is there a way to use the same sub form showing two differant views within the same Main Form. For example: Can I show on one tab a datasheet view and on the other a regular form view. -- Rose Hi Rose, Create a button on your form and under the "OnClick" event put 'Me.DefaultView = Datasheet Alternatively you could use a checkbox If me.checkbox1 = 0 then Me.DefaultView = 2 ' Datasheet Else Me.DefaultView = 0 'Single Form End if me.repaint This should flick the form between datasheet and form views. HTH, Nick. "Rose" wrote: > Is there a way to use t...

Date and time onto a form
Hi, I am designing a form that my client would like the date and time automatically recorded in a field and stored so that when they refer back it shows when the record was done. The 'NOW' function only shows the current date & time and keeps updating. Is there a way of putting the 'NOW' value into a field, then locking it so it doesn't change when the record is reopened. Hope that makes sense! Kazlou The form stores data in a table. You need to add a date/time field to your table to record the date and time a record was last updated. 1. Open the table in desig...

Printing Issues when distributing a form to multiple users
I am distributing a spreadsheet to multiple users. The spreadsheet is being used as a form for data entry. The problem i am having is that when it is being printed, the users are getting varying page layouts where the page breaks have changed, due the changes to the length of the document growing from the free text they are entering. The page breaks that excel chooses don't seem to be spaced well, leading to one or two of the pages being very short (i.e., leaving a lot of free white space), whereas the other pages are taking up the entire page. Is there a particular page layout selection...

Where free 2 sigma statistical process control chart, free?
where can I download a free statistical process control chart template? ...

Statment of changes in financial position
i will be a demo of GP 10 on Weds for a customer who has a requirement for a statement of changes in financial position. Is there any reason that this would be a problem in FRx as long as i know what GL accounts make up each row? Their sales and receivables are going to be maintained in another systmer - with that system providing a journal entry either weekly or monthly. THanks! Andrea: How did this come out for you, also have you done a Schedule of Changes Report?? Pretty standard non-profit reports. "Andrea Smiley" wrote: > i will be a demo of GP 10 on Weds for a cus...

Controlling Gap Width for BAR Chart
Hi, I have the following data for example. A = 2 B= 3 C = 4 I can create a 2 D Bar chart from this quite easily. Now If I make the data to A = 2 , 3 B= 3 , 4 C = 4 , 5 I do want to plot the data on the basis of first two values as mentioned in the first example, but I want to control the width of the Bar from the value given after comma. Please help. On Sat, 24 Feb 2007, in microsoft.public.excel.charting, Fazi <farazahmedtoor@gmail.com> said: >I have the following data for example. >A = 2 , 3 >B= 3 , 4 >C = 4 , 5 > >I want to plot the data on the basis of firs...

Tab Control #7
Hi, I'm using a basic tab control, how to place a bitmap image onto it ? Can a bitmap image be inserted only on the tab strips. (what i mean by tab strips is the part of tab, which holds name for that tab). Also, how to get the 3D effect for the tab ? (Like XP tabs) Hi You can bitblt for each tab clicks. I mean when you change the tab just repaint the dialog with new bitmap. Best regards, Amal Quote raj: Can a bitmap image be inserted only on the tab strips. (what i mean by tab strips is the part of tab, which holds name for that tab). ------------------------------------- Y...

Button form control does not work
I have spent over 5 hours trying to get the button wizard to do a simple thing. Open a form and show data in that form that matches the name in the form where the button is but when i follow the wizard the button allways go to the first entary in the second form eg i have the form (form1) open on emma (record 3) and want to open a second form that also contains emma the wizard puts the following in to a macro form2, Form, , "[Full Name]=" & [Full Name], , Normal but when i test the button it open the second form with the first record which is not emma why d...

Windows Mail spelling control Dutch
Spelling control of my Windows Mail (Version 6.0.6000.16386 / Vista_rtm.061101-2205) is presently limited to English, French, German, Spanish. I want to include spelling control for Dutch. I received below advise, but after donwload and installation of the most recent version of Wlndows Live, no upgrade to below mentioned latest version has happened, nor is there a complement of 37 spell check languages. ********************** Make sure you have the latest version (14.0.8089.0726), and you have to be online to see the full complement of 37 spell check languages. ****************...

continous form question
Hi, I have a 'continous form' which gets its data from a table. Im using a form for ease of use by the operator and data is displayed in text boxes. My form has 6 columns and thousands of rows - so many records in the table. (its pretty much like an excel spreadsheet). However, on my form, i have a text box and i want the text box to change to eg VBred, if the time on the current record matches the time on the next record. (obvousley time is one of the pieces of data and displayed as hh:mm) As my form is a continous form, if i add my 'colour' text box to ...

access forms 12-05-07
how can the minimum value from eight numeric fields be found & displayed displayed on the form, following manual entry? Your only way is through a series of If statements to determine the minimum. Remember, too, that you may need to handle missing data. You can use the Nz function in that case, but you need to be able to assign a reasonable value for comparison purposes if the value is Null. Dim lngMinimum As Long lngMinimum = Nz(Me.Field1, 9999) If Nz(Me.Field2, 9999) < lngMinimum Then lngMinimum = Me.Field2 End If If Nz(Me.Field3, 9999) < lngMinimum Then lngM...

How to control what tabs are displayed in Active Directory Users and Computers
I do not see the value to allow the delegate to change the City, State, Country, Office. What am I doing wrong. (see info below) Also is there a way to limit the view of what is shown in Active Directory users and computers, so the Delegate only sees the General, Address, Telephone and Organization tabs? I know the step below lock them out of the other tabs, but there would be less confusion..even if it is registry hack on that local pc. Here are the steps I have done so far: Step 1. Create a Security Group Called 'XYZ' (call it what ever you want Step 2. Open Active Directory User...

Set a value on a form
I use the following code to open a form DoCmd.OpenForm stDocName, , , stLinkCriteria Is there any way to pass data to the form (through the constructor) or to set the value of a label on the form Thank you, Samuel You can use the OpenArgs argument to pass a value to the new form, and then use the new form's Load event to read the value and put it into a control on itself. First step -- pass the value: DoCmd.OpenForm stDocName, , , stLinkCriteria, , "ValueToPass" Second step - read the value and use it; this code goes with the Load event of the stDocName form: ...

How to find the check form to use for GP 9.0
I don't want to use Deluxe as our check vendor. I want to use Harland. Microsoft MBS sales just gives us Deluxe's phone number, when we request help with obtaining the correct format for Harland checks. Harland has two check formats for GP payable checks. 1) Great Plains Accounting 7.0 - 9.0 2) Great Plains Dynamics Harland isn't sure and can't reference Deluxe. Thanks, John John, From what I can tell from Harland's website, you want the Laser Multi-Purpose checks they show under Microsoft Great Plains. That's the one with the check in the middle, stub on t...

Moving OLE Based Control
I have a control that is bound to an OLE object in a table. When i try to reposition the control with the command Me.ObjectName.Left = 4000, it does not compile. The error message "Invalid Qualifier" appears. In addition, when I normally enter the period after the name of the object such as Me.ObjectName. a list of optional commands comes up. For this control, it does not. Could anyone help with with the problem of not being able to access the properties of this control. I use Access 2000. Thanks -- Frank Wagner fwagner111@aol.com What's the control? Are you sur...

Bill of Lading form
I am looking for a Bill of Lading form for Dynamics for shipments my company makes. Has anyone found a form that works with the system? I know that the German version of the program has one, beets me why the US version doesn't. A reasonably good BOL form can be created using Crystal or SRS. You will need to use some of the optional fields in Inventory to flag any items that may require special handling, if your firm has any such hazardous materials. -- Richard L. Whaley Author / Consultant / MVP Documentation for Software Users Get our Free Tips and Tricks Newsletter and che...

Problem with iif and datediff expression in form
Hi, I have a form where I have to display the value of the field based on some criteria. The first criteria is =IIf((DateDiff("d",[dbo_PWO_Status].[WorkOrderDate],Now())-180)>0,"Y","") and the second criteria to add is dbo_PWO_Status.[Quote] = -1 My first question is how do I accommodate the dbo_PWO_Status.[Quote] = -1 criteria in the iif statement? The second question I have is that with the first expression put in the source for display I am getting Name instead of the Y value for matching condition. I would appreciate any help. Thanks. You n...

Control toolbar turns on with foreign SPAM
I have Word as my editor for Outlook. When I get spam at work, I forward it to the person who handles abuse. Many times, when I forward a spam with a Chinese type alphabet, the Control toolbar turns on and is set for all my Word work until I remove it. I hate those little pop up windows in Word. What causes it to become my default with these spam? ...

How to bind an ActiveX control to a Data Control?
I am building an ActiveX control and I need to bind my control to a data control when using it in VB6. My control is a multi column List. I know I should add a property called "DataSource" that returns the recordset of the Data control, then should move into the recordset and add the records one by one to my list. The question is how can I add the DataSource property and be able to read from the data control and retrieve the data. Is there a direct way or should I do it manually? ...

Controlling indenting when using Word as email editor in Outlook 2002/XP
Is there a way to turn off the automatic indenting of replies that Word 2002 does when it's selected as the default email editor, We'd like to keep word as the email editor, just looking for a customization --Matt In Tools-> Options-> tab Preferences-> button E-mail Options... you can set your reply/forward preferences. IIRC you cannot remove the indent in Outlook 2002 but I know Outlook 2003 dropped the indent on reply/forward -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Backup and Restore -Create an Office XP CD slipstreamed with Servic...

e-mail the current worksheet using a form button
I want to create a submit button that when I click on it, the current worksheet/file will be e-mailed to someone. Instead of saving the file, then inserting into an e-mail. I have seen this before in a file before, but can't figure out exactly how it works. I happened to notice in the VB Editor I saw something like... CommandClick() Excel.Application.Send "myname@email.com" End Sub Or something similar to that. I don't know any VBA.. So if that's what I need to learn, then let me know. TIA Richard, check out Ron's site for a LOT of information on this http://...

Control the number of records shown in a report/subreport.
I've posted this question before and when I follow the advice, I keep getting a circular reference error. So I'm hoping that if I post some more info, I may get insight as to what is going wrong. I have a report (BartS1report) it uses a query (BartS1Report). This report as a subreport (BartS1Sub2) that uses the query (BartS1). The report lists the customer name, address, and systems serviced. The subreport lists the systems serviced. The reports are connected through the Master/Child links Customer ID and the ServiceAddress. When there are more than 20 systems per ...

Macro calling another Macro
Is it possible to call one macro within another macro? If so, how? The macros would be located in the same workbook, but different sheets Thanks, John Sub Macro1() Do stuff here maybe Call Macro2() Perhaps do more stuff here. End sub -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) -------------------------------------------------------------...