Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Retrieving data from a table

Geek News

Retrieving data from a table
Becky 12/27/2008 10:15:00 PM
hello to all

I have an application with about 40 forms and I want to control the size and
position of each of these forms when it opens. I currently do this with code
in each form's Open event like...
DoCmd.MoveSize 150, 250, 1100, 1850

But, I've noticed that there are only 5 different MoveSize settings spread
among all 40 forms. I'd like a way to put these moveSize values in a table,
then have each form look up its values when its Open event is executed. As a
very rusty coder, could some kind soul help me with this?

Much thanks
Becky
Re: Retrieving data from a table
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/27/2008 11:51:07 PM
On Sat, 27 Dec 2008 14:15:00 -0800, Becky
<Becky[ at ]discussions.microsoft.com> wrote:

In each Form_Open event write:
PositionMe Me

In a standard module write:
Public Sub PositionMe(frm As Form)
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblScreenPositions",
dbOpenSnapshot)
rs.FindFirst "FormName='" & frm.Name & "'"
If rs.NoMatch Then
MsgBox "Aarrcchhh, you did not enter coordinates for form " &
frm.Name
Else
DoCmd.MoveSize rs!Right, rs!Down, rs!Width, rs!Height
End If
rs.Close
Set rs = Nothing
End Sub

Create a new table named tblScreenPositions, with fields
FormName, text255, required, PK
Right, number, long integer, required
Down, number, long integer, required
Width, number, long integer, required
Height, number, long integer, required

-Tom.
Microsoft Access MVP


[Quoted Text]
>hello to all
>
>I have an application with about 40 forms and I want to control the size and
>position of each of these forms when it opens. I currently do this with code
>in each form's Open event like...
> DoCmd.MoveSize 150, 250, 1100, 1850
>
>But, I've noticed that there are only 5 different MoveSize settings spread
>among all 40 forms. I'd like a way to put these moveSize values in a table,
>then have each form look up its values when its Open event is executed. As a
>very rusty coder, could some kind soul help me with this?
>
>Much thanks
>Becky
Re: Retrieving data from a table
Becky 12/29/2008 11:24:00 PM
Perfect! Exactly what was needed. Thanks, Tom.

"Tom van Stiphout" wrote:

[Quoted Text]
> On Sat, 27 Dec 2008 14:15:00 -0800, Becky
> <Becky[ at ]discussions.microsoft.com> wrote:
>
> In each Form_Open event write:
> PositionMe Me
>
> In a standard module write:
> Public Sub PositionMe(frm As Form)
> Dim rs As DAO.Recordset
> Set rs = CurrentDb.OpenRecordset("tblScreenPositions",
> dbOpenSnapshot)
> rs.FindFirst "FormName='" & frm.Name & "'"
> If rs.NoMatch Then
> MsgBox "Aarrcchhh, you did not enter coordinates for form " &
> frm.Name
> Else
> DoCmd.MoveSize rs!Right, rs!Down, rs!Width, rs!Height
> End If
> rs.Close
> Set rs = Nothing
> End Sub
>
> Create a new table named tblScreenPositions, with fields
> FormName, text255, required, PK
> Right, number, long integer, required
> Down, number, long integer, required
> Width, number, long integer, required
> Height, number, long integer, required
>
> -Tom.
> Microsoft Access MVP
>
>
> >hello to all
> >
> >I have an application with about 40 forms and I want to control the size and
> >position of each of these forms when it opens. I currently do this with code
> >in each form's Open event like...
> > DoCmd.MoveSize 150, 250, 1100, 1850
> >
> >But, I've noticed that there are only 5 different MoveSize settings spread
> >among all 40 forms. I'd like a way to put these moveSize values in a table,
> >then have each form look up its values when its Open event is executed. As a
> >very rusty coder, could some kind soul help me with this?
> >
> >Much thanks
> >Becky
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net