Modules & VBA :: Define TempVars From A Table?

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 Replies


ADVERTISEMENT

Modules & VBA :: Define Global / Public Variables From A Table?

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

Modules & VBA :: How To Use Tempvars

May 15, 2014

How to use a tempvar in the following line :

Forms!ColdTemperatures![TempVars("Button1")].ForeColor = vbRed

What I am doing is on close of a form I want to change the colour of a button on another open form (the name of the button is held in the tempvar). But I cant get it to work...

View 14 Replies View Related

Modules & VBA :: How To Define A Variable In One Sub Which Can Be Used By Another SUb

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

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 4 Replies View Related

Modules & VBA :: How To Define Accessibility For Different Users

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

Modules & VBA :: Define Current Sub Folder Within Code?

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

Modules & VBA :: Declare / Define Form Variable (Access 2007)

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

Define Number Of Digits In Table Fields

Jul 14, 2005

I'm just to work with Fox Pro, and I am therefore puzzled with how to define the exact number of digits in a field in a table in Access. If I need 9 digits + 2 decimals in a number filed, how do I define that in design view?

Also, I need to know how to export a table into a text file, with a format without any spaces, and each record is divided with a new line. This an old IBM text format file.

Thanks, Torsan

View 1 Replies View Related

Define A Field So That It Is Automatically Filled In With Value From Another Table?

Jan 28, 2015

I would like to define a field (mailingaddresscounty) as type lookup using a field (county) from another table (Zip). But instead of the user selecting from a long list, I would like the selection to be automatically made based on the value of another field (mailingaddresszipcode).The two tables are Organizations and Zips. The user enters the 9 digit zipcode in the organization table (mailingaddresszipcode). I would like the county field in the organization table (mailingaddresscounty) to draw from (link to?) the corresponding 5 digit zipcode in the Zip table (zip) and return the correct county for that zipcode.

View 1 Replies View Related

Modules & VBA :: Define And Setup Array - Find Respective Numbers For A Text String

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

Queries :: Table Of Companies - Allow User To Define Field On A Form

Feb 14, 2014

I have a table of companies, with fields that contain data for 2008, 2009, 2010, etc.

I'd like to design a query that allows the user to define on a form the field, or the year, they want to query. (by text string or some other way, I am good enough with the VBA that I can figure this part out once the beginning part is figured out)

I want 2009 data, I type in 2009 and get 2009 data from a table with many years' worth of data. But I only need one query for all the years.

I notice that this is easy with reports, just use SQL in the the wherecondition, argument, but I can't find the equivalent for queries. I tried putting the text field from the form in the SQL in the query, but could not get that to work.

View 3 Replies View Related

Retriving A Filter From TempVars

Nov 7, 2007

I am modifing the Inventory templete from Microsoft. A form is displayed (inventory transaction list) and you can select a filter for the data. Also on that form you can select a report. I would like to have the report respect the filter. I can see that the filter string is being stashed in a TempVar but haven't yet figgured out how to apply it to the selected report. Any insights would greatly appreciated
Thanks

View 3 Replies View Related

Queries :: Error 3070 Using TempVars In Query?

May 16, 2013

I'm using Access 2007 and have a query in which I have a Where clause that includes a TempVars variable. Here is the SQL:

Code:

SELECT tbl_CostCenter.*, tbl_OpEx.*, qry_OpExByCC.*
FROM (tbl_CostCenter INNER JOIN tbl_OpEx ON tbl_CostCenter.[Cost Center] = tbl_OpEx.[Cost Center]) INNER JOIN qry_OpExByCC ON tbl_CostCenter.[Cost Center] = qry_OpExByCC.[Cost Center]
WHERE tbl_OpEx.[Base Year]=TempVars!CurrentBaseYear
ORDER BY tbl_CostCenter.[Cost Center];

I get runtime error 3070 stating that "The Microsoft Access database engine does not recognize 'TempVars!CurrentBaseYear' as a valid field name or expression." When I run the query without the Where clause, it runs fine, except it includes all years, not just the one I need.

However, when I use the immediate window to check the value of TempVars!CurrentBaseYear, I get a result of 2012 which is what I expected. So how can it not be recognized in the query? I thought that one of the perks of using a TempVars variable is that it can be used in queries.

View 3 Replies View Related

Forms :: Using TempVars For Form Open Criteria - New Or Edit Record

Apr 23, 2014

MS Access 2010 accdb - Using TempVars open forms either for New Record or Edit Record.

Two sets of forms - One set works perfect but the other will not accept the criteria for New Record

MsgBox checks confirm the Variables are still valid in the 2nd form Open Event yet the If Then does not work.

Just before the If Then, an invalid use of Null message appears.

View 2 Replies View Related

Reports :: TempVars In Reports Record Source?

Mar 12, 2015

Access 2007 Sub-Report "rptSubEmployeeProject" inside report "rptProgressReportDay".

I need to dynamically change the table in the sub-report's record source. I tried (line wrapped in code tags below for reading purposes)

Code:
SELECT tblProjectHistory_fldProjectID,
FirstOfHistory, [History Date], [Time Spent],
Employee, fldAssigned, TheFieldPriority,
fldTitle, employeeID, fldTimeSpent,
fldStatus, fldHistoryID, fldOrder
FROM " & [TempVars]![TempEmpTempTable] & "
ORDER BY fldOrder;

And I get the error of invalid bracketing of name and it refers to the [TempVars]![Temp part. Makes me believe that I cannot use TempVars in a Reports RecordSource, is that accurate? If So that leaves me trying to set a sub-reports recordsource via vba right?

View 9 Replies View Related

Define Cascade From SQL

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

Where To Define Relationships?

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

Define Search

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

How To Define This Query?

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

Cannot Define Field More Than Once

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

Can You Define 2 AutoNumbers In Access?

Dec 5, 2007

Hi,

I am trying to create a db for software change requests. I have defined 3 tables:

PCR - Change request table. This table contains all info on the software bug.
Release - Software release table. This table contains info about the release date, platform i.e. SAP
Sponsor - The person funding for the change to take place. This table contains info on the sponsor such as Name.

I have identified that I need a one-to-many relationship between the tables. For example, A release will have many PCR's. A sponsor will have many PCR's they are funding.

My Primary keys are: PCR Table - PCR_ID, Release Table - Release_ID, Sponsors Table - BPM_ID.

In order to get a one to many (the many being on the PCR table) I have put two foreign keys in the PCR Table (Release_ID and BPM_ID). Both of these keys in thier own tables are autonumbers. From my undertstanding to get MS Access to relate the data I need to set the foreign keys in the PCR Table to autonumbers. Or do I? I do not want to change the primary keys in the Release and Sponsors table to datatype number as this would mean user manual input which I am trying to avoid.

Thanks in advance for the help.

Ket

View 1 Replies View Related

Define A Rank In Query

Dec 27, 2007

Dear all
i have a trouble to define a rank in query, i have a table named SALES
like below

region PRoduct qty
jabar A 10
Jabar B 20
Jabar C 30

Jateng A 50
Jateng B 40
Jateng C 35

i want to give a result in my query like below

region PRoduct qty Rank
jabar C 30 1
Jabar B 20 2
Jabar A 10 3

Jateng A 50 1
Jateng B 40 2
Jateng C 35 3


anyone can help me???thanks

regards

martell

View 1 Replies View Related

Error Message-cannot Define Fields More Than Once

Dec 16, 2004

I'm trying to add filds to a table, and when I try to save I get the error message: cannot define fields more than once. The problem is, there are no duplicate field names. I've run compact and repair (several times) with no change.

Any ideas?

Thanks,
Mary

View 1 Replies View Related

General :: Define Primary Key To Show In Default Value

Feb 10, 2013

I would like to define primary key to show in default value "n/=Right(Year(Date());2)"

n - next real number
=Right(Year(Date());2) - equal two last digits from year

The big problem is when we have next year e.g. 2014 real number should count anew.

E.G 6/13, 7/13, 8/13, 9/13, 1/14

View 3 Replies View Related

Forms :: How To Define Position Of A Navigation Button

Jun 3, 2013

Is it possible to define the position of a navigation button. For example, I want my first navigation button not starting totally on the left but a bit indented. Possible?

Secondly, suppose I have combo boxes on my first navigation button and for each combo box and choose a value, next I move to the second navigation and then back to the first navigation button. Then it always seems that the values of my combo boxed are reset to default value. Can this be avoided?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved