Modules & VBA :: Function To Define Colors
May 1, 2014
I have one color scheme I want to use all through the database I am developing. The next examples have just one color defined, to make it simpler (a dark blue, that I would call B1)
Code:
private sub setlabel()
Dim B1
B1 = RGB (0,52,105)
me.label1.forecolor = B1
end sub
... however this means I have to repeat the color definition every sub, so I thought would be neater to define a function to set my color codes (I have 20 colors).
Code:
Function SetColor()
Dim B1
B1 = RGB (0,52,105)
End function
My objective, is when I'm working in forms, Iwould (ideally) call this function "setcolor" and just write my code for the blue. I tried the examples below:
Code:
Private sub setlabel()
SetColor()
me.label1.forecolor = B1
end sub
[code]...
Again, this is probably some definition of arguments or dimensions that I am not aware oh. How to predefine the colors in a function to give them a "short" code which I can call in any sub in the database?
View Replies
ADVERTISEMENT
Mar 4, 2014
Question 1:
I am attempting to make a macro to pull information based on a clicked button to provide information to another form. While my example below will be rudimentary, I am attempting to create so that it can be applied to 450 buttons, hence the need for it to be a macro and not simply code per button.
For example if I have 3 buttons, captioned: red, green and blue. If I click on the blue button, it will open another form with a text-box that will say 'blue'. Likewise, if I click the red button the text-box will be changed to 'red'.
In the code below the section that I need to change is: Command1.Caption. Using this data I can pull from the one button to create the value, but I need it to be based on an OnClick or something in order to pull the value from the right button.
Example:
Function Macro1()
On Error GoTo Macro1_Err
DoCmd.OpenForm "Form2", acNormal, "", "", , acNormal
Forms!Form2!Text0.Text = Forms!Form1!Label0.Caption
DoCmd.GoToControl "[Text2]"
Forms!Form2!Text2.Text = Forms!Form1!Command1.Caption
[code]...
Question 2:
I am trying to use a query to change button colour on the basis of values stored in a table.What I want to do is change the button background after comparing the button name to the same variable in a table, and determining another variable.
IE:
Button1, Button2. In table: Button1, Val = Y, and Button 2, Val = Z
Pseudo Code:
Array: From Button1 to Button2
Query for Button1 against table
If Val = Y, Button1.background = red
Else if Val = Z, Button1.background = blue
Else Button1.background = black
End if
View 4 Replies
View Related
May 12, 2014
How can I define a variable which can be used by another Sub and of course the value stored in it?For instance:
Private SUB A ()
DIM A1 as String
A1 ="ABC"
END SUB
PRIVATE SUB B()
PRINT A1
END SUB
View 5 Replies
View Related
Oct 28, 2014
I have a multi-user database. I would like based on the logged-in user, some buttons and controls in different forms be disabled and the others be enabled.
There is a login form that gets the username; I made also a function to define authorities for users in it.
My plan is that when user enters to the database, on load of the main menu the function calls and disables the defined controls in different forms. I tried to use this kind of codes:
Function User_1()
[Forms]![frmMainMenu].[cmdUpdateDatabase].Enabled = False
[Forms]![frmChooseReports]![cmdOrdersFollowUpReports].Enabled = False
End Function
Function User_2()
[Forms]![frmMainMenu].[cmdChooseCharts].Enabled = False
End Function
But this code only works for the forms that are opened at the moment and if one of them is closed the system gives Error.
View 2 Replies
View Related
Sep 25, 2013
I have a table which is formatted as shown:
ID, My_Var, My_Value, Notes
This table holds variables that I want to declare to use throughout my application. I have been told in another thread that tempVars are the best way to do this.
I have written the following code, which works on a limited basis:
Private Sub btnSetVAr_click()
TempVars.Add "udvVar", Me!My_value.Value
End Sub
This defines a single variable on each button press, fine to work out how the code works, but not much use. What I really need to do is when the initial menu screen loads to call a routine to assign all the variables stored in the table using a loop to do this. The idea is to make all variables values easy to edit or add to, rather than have to edit code each time we need to change them.
The variables table holds 14 records so far, such as:
My_Var, My_Value
EuroRate, 0.885
ConDisc, 0.9
MollDisc, 0.8
As well as holding numbers, they hold strings and date values.
So, on loading the initial form, use an event to assign the variables from the table using the tempVar name as the value held in "My_Var" and it's value as held in "My_Value"
View 6 Replies
View Related
Oct 9, 2014
I am trying to define a path to identify a current folder - I'll try and explain the way the following code works first (and it does work 100%)
The following code identifies folders and sub-folder structures and imports them (their structures and folder paths and filenames) into a DB
It also simultaneously retrieve's any xml docs within those respective folders and imports the XML data into the same database ........ and then moves those folders into a "processing folder" location.
Cool yes, but I can only import the XML doc's at the moment, by hard coding the path (like this):-
path = "C:UsersjeremybDesktopsnapmadXYZ123XYZFILES 0061940"
The code is highlighted as above - in the FULL code below:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Code Begins:-
Option Compare Database
Option Explicit
[Code]....
View 2 Replies
View Related
Jul 23, 2013
Access 2007: I have a continuous form which, when it opens, uses code to display alternating colors... I need to set a default 'alternate' colour, and I want to find the code to use for Light Grey - on the design of a form, the color to use on a control would be #903C39 but when I try to set that as my default colour in the code it doesn't like it! I can use vbRed, vbBlue, vbYellow, etc, and that works perfectly but I can't find a vbLightGrey
View 6 Replies
View Related
Sep 4, 2013
I would like to declare Global or Public variables from a table so they can be added to or edited easily. I had the following function to do this with Alpha Five but at the moment my lack of knowledge of Access VBA is making this task difficult.
Here is the function that I use in Alpha:
FUNCTION udVars AS A (udTabName AS C )
dim codeStr as c
t=table.open_session(udTabName,file_ro_shared)
t.fetch_first()
while .not. t.fetch_eof()
[Code] ....
It opens a table reads in the records and then makes them into a string the string would look something like this:
"Public EuroRate as Single = 0.885"
I would then need to use this string to declare the variables but not sure what command to use - I was looking at the Eval function last night but couldn't get this to work...
The table would hold strings for all the above so you would have:
My_Var (variable name)
My_Typ (type of variable e.g. Single)
My_Val (value e.g. 0.885)
The table would hold as many variables as required, some would be dates, some paths for making directories and some would be numbers.
View 6 Replies
View Related
Jul 16, 2013
Is it possible (and how...) to declare a module-specific form variable (or any variable for that matter) at the top of said module, so it doesn't need to be set at the start of each subsequent procedure?
I have a module of code specific to one form with a number of procedures, each one of which requires me to Dim / Set the form variable. It would be much neater if I could do it once at the start.
Code:
Option Compare Database
Option Explicit
Public Sub Populate(lngParameter As Long)Dim frm As Form
[Code] ......
View 5 Replies
View Related
Apr 21, 2015
I need to find the respective numbers for a textstring when for
abcdefghijkl stand the numbers
79 81 82 83 84 85 86 87 88 89 91 92
The textstring to "decode" is for example is 'adgjk'
The result (79 83 86 89 91) should be added into a table by Looping.
rs.Addnew
rs("Letter")= myarray??
rs("corNumber")= myarray?
rs.update
rs.movenext
Something like this.
But I cannot define and Setup the Array, which should be the best way for doing this.
The Array does not change its Content nor its Dimension.
Both, letters and numbers are strings.
View 14 Replies
View Related
Dec 11, 2013
So basically I need making a function that will count the number of records from another table/query based on a field from the current query.
View 2 Replies
View Related
Nov 24, 2005
When I opened my database today, all the tables had turned blue??
Does that signafies anything? How can I reset the table in plain white??
Any help is appreciated!
bboschker
an absolsute access beginner!
View 2 Replies
View Related
Feb 15, 2005
Anyone know how to convert a color code from something like:
#E1E1E2
To something that Access will recognize?
Thanks,
Ken
View 2 Replies
View Related
Feb 13, 2007
I have a subform that returns a bunch of records. Each of the records returned has a LANE_ID, so in this example, there are 10 records returned, 5 with LANE_ID = 11111and 5 with LANE_ID = 22222. Is it possible to alternate the backgrond color for each of these groupings?
I have found examples of how to change the color of alternate rows, but I can't find anything that would tell me if what I want to do is possible.
View 1 Replies
View Related
Aug 8, 2005
How I can do a form whit a list box whit different colors for each record ?
Thank you
View 5 Replies
View Related
Dec 22, 2005
Hi, All...
Can someone tell me how to change the color (back and fore) within a combo box? I have set both in the properties window and it works fine but, as you scroll through the list within the box, the colors of the active line (back and fore) change to something completely different.
Any assist would be greatly appreciated!
Thanx ;<)
Karen
View 2 Replies
View Related
Oct 12, 2004
Hi, all... :)
I need to create cascade relationship on fly.
I've succeeded to create the relationship by:
ALTER TABLE tName ADD CONSTRAINT fk_id FOREIGN KEY(ID) REFERENCES tPrimary(ID)
and even succeeded to check the referential integrity by:
ALTER TABLE tName ADD CONSTRAINT fk_id FOREIGN KEY(ID) REFERENCES tPrimary(ID) CASCADE
The real problem comes when i am trying to enforce the cascades. I do not find any expression doing it.
the standarts of sql: on update cascade
or
of sql server: on update cascade go
just don't work in access :(
Thankful ahead
View 1 Replies
View Related
Jul 12, 2007
Hello,
My Access application consists of two MDB files: the application file and the database file. The application file has links to tables from the database file.
Now, I want to define relationships to optimize my database performance. Where should I define them? In the database file? In the application file? Both?
Thank you!
View 3 Replies
View Related
Apr 18, 2006
Hi!
I have a table with x columns.
In a form I can choose 4 different columns to define my search.
Now, I have this SQL-statement, that strangely doesn't work. Can someone help me with this?
SELECT a.Nr, a.Objekt, a.Applikation, a.Modul, a.Datum, a.Anmalare, a.Onskemal, a.Klart, a.Prio, a.Status, a.Ansvarig
FROM tblArenden AS a
WHERE ((IIf(Not IsNull(Forms!frmFiltrera!cboObjekt),a.Objekt Like Forms!frmFiltrera!cboObjekt & "*","*"))<>False) And ((IIf(Not IsNull(Forms!frmFiltrera!cboApplikation),a.Applika tion Like Forms!frmFiltrera!cboApplikation & "*","*"))<>False) And ((IIf(Not IsNull(Forms!frmFiltrera!Prio),a.Prio Like Forms!frmFiltrera!Prio & "*","*"))<>False);
View 1 Replies
View Related
Apr 8, 2007
Hi
I need to define this query:
I have 2 unbounded fields : ShowMonth and ShowYear (Each field represent the month and the year of Date field)
And UserName field
I need to define query that shows the dates and the UserName accordding to ShowMonth,ShowYear and UserName field (Without SQL).
I will be happy if serious answers will be post
Thanks
View 3 Replies
View Related
Oct 23, 2013
I am trying to save my table and I get a message saying "Cannot define field more than once". I only have 14 fields and none of them are repeated. My field titles are: First Name, Last Name, SSN, Wage, Salary, DOB, Hire Date, Years Employed, Phone Number, Alternate Phone, Address, City, State, and Zip. What am I doing wrong?
View 1 Replies
View Related
May 3, 2006
Hello everyone,
Does anyone know how to translate the background colors used in Access to RGB?
Thank you.
View 3 Replies
View Related
Jan 13, 2006
I built a really good database and now I want to dress it up a bit. Does anyone know how to change the color of a command button ? (access 2003)
Thanks:rolleyes:
View 2 Replies
View Related
Sep 16, 2004
reading code behind form and came across:
&HFHEFEF, and &HFFEFFE and the like relating to certain colors: where is this magical "chart/table" of equivalents? Need soon..thanks..teball20 (teddy)
View 1 Replies
View Related
Oct 6, 2004
Hi
Is there a way to have alternating colors in a form?
I would like every record to alternate between Grey and White.
Thanks!
View 1 Replies
View Related
Nov 8, 2014
I am trying to see if it is possible to store colors in a form or table and then reference them while in VBA. What I am hoping to do is when I write all my code for command buttons to change On Got Focus, instead of writing xxx.backcolor = RGB (255,255,255) i could do something like xxx.backcolor = Forms!HiddenColors!Command That way if i want to ever change the color scheme of the db, I can change it in one place rather than hunt lines of code.
View 6 Replies
View Related