By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Update form formatting on FLY?

P: n/a
Hi Everyone,

Is it possible to create some code which can automatically update my
forms formatting?
I have a small database with a form which is periodically changed. When
the db is returned to me the form looks completely different. Different
fore- and background colors, font types etc...

Is there something in code I can use to set the form back to how I
normally use it?

Marco

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<vo***********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi Everyone,

Is it possible to create some code which can automatically update my
forms formatting?
I have a small database with a form which is periodically changed. When
the db is returned to me the form looks completely different. Different
fore- and background colors, font types etc...

Is there something in code I can use to set the form back to how I
normally use it?

Marco


Whilst it is possible to do this, if someone is altering the design of the
form against your will, they could alter the code too. If you sent the
database to be altered, but didn't want this form to be touched, then what
did you need changing? Perhaps just the data? Also, are you sure the other
person is not expressing the same frustration that someone keeps changing
the form design.
If you only needed the data changing then consider splitting the database
front end (forms, reports, etc) and back end (only data tables). Send
across both bits but only use the returned backend.
If the person is changing the form because he has problems with his eyesight
or has a small/low resolution monitor, then it may make sense for you to
keep different front ends. If there is no real reason for the form to be
changed, then you could send an mde file to lock down these changes.
If you still require code, then post again, but basically you can set things
like this in the form's open event. Write a sub/function in a module so it
can be re-used for multiple forms, so you could write SetupForm(Me)

Public Sub SetupForm(frm As Form)

frm.Detail.BackColor=255

For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acLabel: ' Format the label
Case acTextBox: ' Format the textbox
Case acComboBox: ' Format the combobox
Case acCheckBox: ' Format the checkbox
End Select
End With
Next ctl

End Sub


Nov 13 '05 #2

P: n/a
Brian,

You are right all along. The only problem is, the guy is my boss.... he
keeps making changes to the mdb, which is good of course, but he has
something with forms with a brown background.
I on the other hand want to just the common grey. So I need something,
like you wrote, that I can code into the database once he gets me an
updated version again.

Is there a way I could copy that code from lets say another database
which I call: MyDefValues.mdb into his updated version?

Marco

Nov 13 '05 #3

P: n/a
<vo***********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Brian,

You are right all along. The only problem is, the guy is my boss.... he
keeps making changes to the mdb, which is good of course, but he has
something with forms with a brown background.
I on the other hand want to just the common grey. So I need something,
like you wrote, that I can code into the database once he gets me an
updated version again.

Is there a way I could copy that code from lets say another database
which I call: MyDefValues.mdb into his updated version?

Marco

I am not sure if you both might be changing data, form design, form coding
or what, but if you both agree you need different colours then you need to
identify yourself somehow so the application knows which colours to use.
The example code could be put into a new module, and in the open event of
each form, you write "SetupForm Me".
This example simply looks at your Windows login, and if it is you then your
colours are shown, otherwise his are used. You could extend the code to
change textbox fonts, etc and possibly amend the code so the settings are
read from a table rather than hard-coded as I've done here.

Private Const MY_WINDOWS_LOGIN As String = "Marco"

Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function WinLogin() As String

Dim lngResult As Long
Dim strLogin As String

strLogin = String$(254, 0)

lngResult = GetUserName(strLogin, 255)

If lngResult > 0 Then
WinLogin = Left$(strLogin, 254)
End If

End Function

Public Sub SetupForm(frm As Form)

' If it's me then show the standard colour
If WinLogin() = MY_WINDOWS_LOGIN Then
frm.Section("Detail").BackColor = -2147483633
End If

End Sub
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.