UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Open form at cursor location in continuous form    
 
   
drektegek
post Oct 28 2008, 07:25 AM
Post#1



Posts: 4
Joined: 4-March 08
From: Amsterdam, Netherlands


Hi all,
I've created a continuous form with a button, so for every record this button will be copied. I'm trying to open a form at the exact cursor location in a continuous form when the button is clicked. The problem is that you can't refer to the location of the button in a continuous form because Access will only remember the location of the button in the first record. I've searched the internet for a solution, tried some, but I can't find a proper solution. Things I took an eye on are the examples of Lebans:
http://www.lebans.com/openform.htm
http://www.lebans.com/setgetsb.htm
http://www.lebans.com/conformscurcontrol.htm
The GetSetScrollbar function works only with recordsets larger than the form. This is a bug in the GetSetScrollbar function of Lebans. For example when you have 10 records and the form can handle/view 25 records you still have a scrollbar you can manipulate. When you scroll down, the scrollbar position remains the same so the function won't give the correct result anymore :(.
Otried to get the cursor location with the GetCursorPos API ( http://support.microsoft.com/kb/152969 ). But this doesn't work also (and I didn't forget to convert to twips wink.gif ).
Lebans created in his MonthCalendar ( http://www.lebans.com/monthcalendar.htm ) the right solution for this problem (see version 9.1). I got some good VBA skills but this code is way beyond my league dazed.gif. I can't extract the parts that will give me my solution.
Does someone know another solution for this problem or knows how to extract the function from Lebans's MonthCalendar??
Thnx in advance!
Greets,
Derek
Go to the top of the page
 
JVanKirk
post Oct 28 2008, 07:36 AM
Post#2


UtterAccess VIP
Posts: 4,209
Joined: 4-March 04
From: Clarksville, TN


Welcome to UA.
Are you saying that you want your form to open up under the button you just clicked. So if you are at the third button down and click, the subform will open just below the third button, or are you saying wherever you click on the form at all...almost like a toottip??
J
Go to the top of the page
 
drektegek
post Oct 28 2008, 07:46 AM
Post#3



Posts: 4
Joined: 4-March 08
From: Amsterdam, Netherlands


Hi Jason,
Thanks for your fast reply. I would like the first. Like open up a form just below the third button when clicking on the third button.. open up the form just below the 10th button when you click on the 10th button.. etc.
But I couldn't accomplish that so that's why I was searching for an other solution (the cursor location).
Gr.
Derek
Go to the top of the page
 
JVanKirk
post Oct 28 2008, 07:51 AM
Post#4


UtterAccess VIP
Posts: 4,209
Joined: 4-March 04
From: Clarksville, TN


I will mess around a bit and see if I can figure something out using the cursor location on the form because I can't see the button method working since it's a continuous form...cursor is going to be more reliable.
Go to the top of the page
 
drektegek
post Oct 28 2008, 08:17 AM
Post#5



Posts: 4
Joined: 4-March 08
From: Amsterdam, Netherlands


Jason,
I've found a solution sad.gif. When searching on UA I've found this example:
http://www.utteraccess.com/forums/showflat...6&bodyprev=
Ocopied the code for positioning the calendar and modified it a bit. Works great now.
Thanks for your help! And if you can make a shorter version of the code or a better solution than I would be glad to test it!
Gr.
Derek
Go to the top of the page
 
JVanKirk
post Oct 28 2008, 08:28 AM
Post#6


UtterAccess VIP
Posts: 4,209
Joined: 4-March 04
From: Clarksville, TN


Is this what you used?
CODE
Private Sub SetWindowPosition(frm As Form, xWidth As Long, xpos As Long, ypos As Long)
    Dim r As RECT
    Dim lngRet As Long
    Dim lngFormHeight As Long
    Dim lngFormWidth As Long
    Dim xxpos As Long, yypos As Long
    Dim xRes As Long, yRes As Long
    xRes = apiGetSys(0)
    yRes = apiGetSys(1)
    lngRet = GetWindowRect(frm.hwnd, r)
    lngFormWidth = r.right - r.left
    lngFormHeight = r.bottom - r.top
    xxpos = xpos
    yypos = ypos
    If ypos - lngFormHeight < 1 Then
        yypos = lngFormHeight
    Else
        If ypos + lngFormHeight > yRes Then
                yypos = yRes - 150
        End If
    End If
    If xpos - xWidth < 1 Then
        xxpos = 1
    Else
        If xpos + xWidth > xRes Then
            xxpos = xRes - xWidth - 20
        End If
    End If
    lngRet = MoveWindow(frm.hwnd, xxpos, yypos - lngFormHeight, xWidth, lngFormHeight, 1)
End Sub

If so, then I have nothing shorter. Found a method on another site but it's a bit longer..and requires modules where this looks like it resides with the module behind the form and that's it...looks way simpler!!
Glad you got it...
J
Go to the top of the page
 
drektegek
post Oct 28 2008, 08:42 AM
Post#7



Posts: 4
Joined: 4-March 08
From: Amsterdam, Netherlands


Yeah that is what I used.. Good to hear that it's the shortest solution.
roblem solved, so one worry less!
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 02:51 AM