Environ Variable

Mar 19, 2006

I have written a code in VBA to get username. The code is strUserName = Environ("Username")

This doesn't seem to work in some computers. Any idea why?

View Replies


ADVERTISEMENT

Environ

Oct 10, 2006

I was given this piece of code the other day by somebody on the forum and it works really well. My question is:

Is there a way, using a similar function that I can retrive the IP address?

Environ("ComputerName")

View 4 Replies View Related

Environ() As Login?

Mar 9, 2006

Hello,

I use Environ("Username") all the time, most frequently for logging who has done something to a record, and have once used it to log people into the database (very basic, much the same as logging who did what to records).

But I was wondering, how feasible is it as a security measure?

I often use it on the main menu of my DBs to give me a different menu (with more advanced options on) than other users.

Is it really that safe to use it as a means to allow people in, or stopping them? I know that obviously you have to stop them getting in other ways (holding shift for example), but assuming all of that is done, in theory, they should only be able to get in if they can log in as an authorised user?

Don't know why it is just struck me - just curious I suppose!

View 2 Replies View Related

Network Environ Help

Nov 10, 2006

Hi everyone

I have searched for help on this forum and all over for a while but cannot find the help i need.

I have a database stored in my user area on a schools network. Other users around the school access the database by clicking on a shortcut to it found on their start menu. The database is not split with a fe/be and usernames and passwords are not required to log on, they simply click the link.

I would like to know how I can find out which users have the database open at any given time? I have a piece of software that tells me the computer name but that is no use, I need the users name. Is there a way of pulling this from the network because each user must first log on to their computer using their name and password before they can access the database?

Any suggestions appreciated
James

View 3 Replies View Related

Environ Function In A97

Mar 10, 2005

i have a menu which recognises a user by using the environ function.

the problem i am getting is that with a small number of users the environ function isnt recognised by the system?

it gives them a #name# instead.

the crazy thing is that it also happens on simpler functions such as =Now() and =Date() which is really annoying, as these 3 things are a foundation on anything that is done within the system/!

the majority of users have no problems, which makes it even more annoying!

when i try to go into the properties of the label which has been assigned the function i get a message. (only on affected PC's)

see attached for pic

THANK YOU IN ADVANCE. HELP IS REALLY APPRECIATED!

View 12 Replies View Related

Modules & VBA :: Use The Environ Username Somewhere In The Db?

Mar 27, 2014

Using Win 7 and Access 2007

db will be split and on a server

If it's possible: Would like to use the Environ username somewhere in the db so the user only sees their records.
Where would I place this? Or is their different code I should be using for this purpose???

View 5 Replies View Related

Modules & VBA :: Environ Username Function - Comparing Results

Apr 8, 2014

I am trying to use the Environ Username function, which i have working! But i want to compare the result with a Username Table to determine if they have access etc...

View 13 Replies View Related

Reports :: Subform Field Linker Error - Obj Variable Or With Block Variable Not Set

Apr 16, 2013

I am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.

The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".

I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.

Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.

View 2 Replies View Related

Modules & VBA :: Error 91 - Object Variable Or With Block Variable Not Set

Jul 8, 2013

Error 91 - Object variable or With block variable not set

I am getting this error telling me that an object variable is not set.

I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?

View 14 Replies View Related

Modules & VBA :: Sorting / Object Variable Or With Block Variable Not Set

Oct 3, 2014

This code runs fine the FIRST time, however trows up a message the SECOND time it is run.

The error is on the line ".Range"

I am trying to sort records which have been exported to Excel.

Dim LR As Integer
LR = 5
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set wbRef = xlApp.Workbooks.Add
With wbRef

wbRef.Activate
.Worksheets("Sheet1").Activate
With ActiveSheet
.Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes
End With
end With

View 3 Replies View Related

Modules & VBA :: Update Contents Of Variable But Not The Variable Itself?

Aug 20, 2014

I look at a lot of files to see when they were last updated. I wanted to write a generic procedure to manage that so ..

Code:
Public fDate As Variant
Public vField As String
Public vFile As String

'GTSdata
vField = "txt_gts_data"

[Code] ....

What I hoped Me.vField would do is update the date field [txt_gts_data] on my form with the date the file was last saved.

i.e. me. txt_gts_data = fDate

What actually happens is the variable vfield gets updated from "txt_gts_data" to 19/08/2014 then later code falls over because the fieldname is lost .

Me.[vField] corrects itself to me.vField (and does not work)
Me!vfield falls over (cannot find the field vField, not surprising J)

How do I say update the contents of the variable, not the variable itself?

View 7 Replies View Related

Reports :: Object Variable Or With Block Variable Not Set

Apr 15, 2015

Runtime error '91'

Running Access 2010.

I have two reports running off of the same crosstab query. I copied one report to make the second report, then modified the second report to change the background of column fields satisfying certain conditions. These lines of code were added to the Detail_Format section, in color below. The report with the extra code lines does not error--the original report errors.

Code:
Option Compare Database
' Constant for maximum number of columns EmployeeSales query would
' create plus 1 for a Totals column. Here, you have 9 employees.
Const conTotalColumns = 11

[Code] .....

If I say OK (rather than debug) after the error message, I can then click the button for the report again and it runs without complaint. And, as I said, the report with the added code never errors.

View 4 Replies View Related

Environ$("USERNAME") And Access 2003

Dec 31, 2006

How do I use the following as the default value of a textbox in Access2003?
Environ$("USERNAME")

Resolution:

Create Module and insert the following code:

Option Compare Database
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
On Error GoTo fOSUserName_Err

Dim lngLen As Long, lngX As Long
Dim strUserName As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If


fOSUserName_Exit:
Exit Function

fOSUserName_Err:
MsgBox Error$
Resume fOSUserName_Exit
End Function

Use this function as default value
=fOSUserName()

View 9 Replies View Related

=Environ("UserName") Not Working In Query

Aug 16, 2005

Hi I am using the below code for getting Windows Username, this code is working fine when i am using this in lable, however if i use this in a query, it is not working, do it need some kind of autorun?

SELECT Associates.*
FROM Associates
WHERE (((Associates.CorpID)=Environ("UserName")));

Please help.

View 2 Replies View Related

Object Variable Or With Block Variable Not Set

Apr 23, 2006

I have a networked database. It is accessed with computers that have both Office 2002, and office 2003. I get the following error message on computers with Office 2003:

"Object variable or With block variable not set"

It happens occasionally and the problem generally fixes itself so I dont think there is anything wrong with my coding.

And when it happens on the computers with office 2003 the ones with office 2002 can open the database fine.

What can be causing this?

Thank you in advance

View 1 Replies View Related

Object Variable Or With Block Variable Not Set

Dec 14, 2006

Good afternoon all,

The following block of code was working great until I came into work this morning. This routine is called from the OnClick event of several combo boxes. When it does, I recieve the error listed above (Object variable or With block variable not set) on line:

If Me.cbxAss_Filter <> "All" Then

Any ideas? I'm running on no sleep in the last 24 hours so I'm sure I'm missing something simple

The code itself checks the contents of a form and builds a string of conditions which I apply to the Form's filter property to filter records.


Code:Public Sub CreateFilter() '************************************************* **** 'Name: CreateFilter 'Purpose: Generate a string to filter the form 'Inputs: None 'Outputs: None 'Instigates: Me.Filter ' 'Updated: 11/30/06 'By: Chris Lounsbury '************************************************* **** 'Vars Dim strFilter Dim lngLength As Long strFilter = Null strFilter = "" 'Each filter box has its own check for contents If Me.cbxAss_Filter <> "All" Then strFilter = "assigned = '" & Me.cbxAss_Filter & "' AND " End If If Me.cbxAction_filter <> "All" Then strFilter = strFilter & "action = '" & Me.cbxAction_filter & "' AND " End If If Me.cbxStatus_filter <> "All" Then strFilter = strFilter & "status_rsrch = '" & Me.cbxStatus_filter & "' AND " End If If Me.Combo34 <> "All" Then strFilter = strFilter & "rims_flags = '" & Me.Combo34 & "' AND " End If If Me.cbxAAMB_filter <> "All" Then strFilter = strFilter & "aamb = '" & Me.cbxAAMB_filter & "' AND " End If 'Check if filter string was built If strFilter = "" Then Me.FilterOn = False Else 'Determine length of Filter String 'minus the trailing ' AND' lngLength = Len(strFilter) - 5 'Chop off ending ' AND' and set the form filter If lngLength <= 0 Then Else Me.Filter = Left(strFilter, lngLength) Me.FilterOn = True End If End If 'debug 'MsgBox (strFilter) End Sub

View 1 Replies View Related

=Environ("username")

Jun 14, 2005

I have noted a problem on 2 computers using this. There are around 30 or so computers on our network that work fine with this as a value. The majority of the users are at Access 2000 but some have Access XP. The offending machines have Access 2000

One day a persons computer crashed. DP imaged another persons machine and installed the image on the crashed machine as a solution. Since this the =Environ("username") returned #Name$ (not sure of the exact syntax on this). This same trouble surfaced on another machine recently. I unlocked the field so the users could enter their correct name but this can lead to errors and I would like to keep the username locked and read by code.

I checked the references on the offending machine and they were ok. Not sure what else there is to do to rectify this.

If anyone else has had a similar trouble and found the solution I would appreciate hearing about it.

Thanks a lot!!
-----------------------------
Edit:
I just checked the machine and corrected the syntax above. I also found that in a date search form where I have =now$() for a field, the same thing is displayed - #Name$ rather than the date.

View 9 Replies View Related

Please Help: "object Variable Or With Block Variable Not Set"

Mar 1, 2006

I get this error message, " object variable or with block variable not set", when I'm in the design view of a form wanting to use the command button wizard. Using a brand new database/blank I imported a table from my database in question. I then tried to make a new form and put a button on it. It worked for awhile but then when I close the database and reopen it to add another button to the same form, I get the error message again. It isn't a problem that is specific to my homeschool database. It affects all the database I use/maintain as well as any new "test" databases I've made trying to figure out this problem. I looked at references before and after the error occurs and there is not difference. I've also looked at code but don't see anything code that requires variables to be defined. In the case of the test database with one table and one form there is no code to look at until I make a button before exiting and even then, I don't see anything weird.

I would appreciate any help you can offer.

I've attached the original database I was working on when the problems began.

Is it possible for a database program to adjust security levels on certain reference libraries when installed on ones computer, thus making all other database act up that are using those libraries?

Thanks,
Kris

View 3 Replies View Related

Variable Help

Apr 25, 2008

Hi All,

Getting myself in a pickle with variables & forms so any help on the following would be appreciated.

I'm building a client management database and currently have the following setup:

1) tblclientdetails (primary key cdid)
2) frmclientdetails (record source tblclientdetails)
3) cmdopenques (opens frmhealthcheck)
4) frmhealthcheck (record source tblclientdetails)

Once client details have been entered into frmclientdetails and the user has clicked cmdopenques, I would like frmhealthcheck to default to the client details entered. I've tried setting variables in VBA & using a queries/pop ups but can't seem to get this to work

Any help/instructions would be great

Thanks!

Jules

View 1 Replies View Related

Variable

Mar 9, 2006

I have created a Sales Report with Groupings of KeyID then CustID. I am not displaying Detail, CustID Header or Footer. In the KeyID Footer I need to display all CustID's that are included in the KeyID totals.

I have tried adding this code but get a error 2427. GroupFooter3 is the CustID footer.

Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As Integer)
Let KeyGroup = KeyGroup & "," & Me.CustId
End Sub

Private Sub Report_Open(Cancel As Integer)
Dim KeyGroup As String
Let KeyGroup = "Includes"
End Sub

Also I have added a text box with the control =[KeyGroup] which doesn't seen to work.

Any help would be much appreciated.

Thank you,
Valerie

View 2 Replies View Related

Public Variable

Sep 16, 2005

Why can't I set a controls default value to a public variable?

View 2 Replies View Related

Assign Variable From SQL

Dec 28, 2005

I have a table set up like this:

tbl_original
account, invoice
11111, 1
22222, 1
33333, 5
44444, 3

I want to create a function module or something similar which will assign a variable to the max invoice # used on that table, using sql if possible. I tried something like this, but it's not working.

Public Function max()

Dim maxinvoice As String

maxinvoice = "SELECT Max(tbl_original.invoice) AS MaxOfinvoice" & _
"FROM tbl_original;"

MsgBox maxinvoice

End Function

I would like the msgbox to popup saying "5", since that is the max invoice # used based on the above table.

I don't have too much experience using modules on their own without forms and variables on the form to assign to, can someone make a suggestion?

Thanks in advance!

Vassago

View 14 Replies View Related

Variable To Label

Jul 26, 2006

Hi folks,

In code i have built a string variable called strRAG which is a combination of text "Me!lbl" and another variable called intSiteID, which forms for example label name Me!lbl51.

I have a form with loads of labels on it and what i want to do is use this string to set the BackColor of the label.

The code i use loops round building up different label names but i am have problems relating the strRAG detail to the form labels.

I have posted this question in VBA early this week but after looking at the wording i have tried to rephrase it.

Thanks
Mark

View 3 Replies View Related

Getting SQL Results As A Variable

Aug 9, 2006

I'm trying to run an SQL statement to Sum the values of a table column. No problem. It would be useful for me to take that total and be able to set it equal to a variable within my VB code that's running, I just don't know how to do that, I'm very new to VB programming.

I cannot find help anywhere on the internet for this. :( I'd like to do something like this, just don't know how:

VariableName = Run.SQL ("Sum(tblName.Column) AS SumOfColumn FROM tblName")

I'm not a programmer by trade, so I am picking up things piece by piece, and just cannot find my way out of this task. Thanks for your help guys.

View 1 Replies View Related

'Temp' Variable...

May 22, 2007

Hi there - on one of my forms i have a text box where the user can write the contents of a letter. When a button is pressed, a report is run, and the text from the form is entered into the report -

this all works fine - but when the text reaches a certain length, it goes all unreadable. SO i assume this use of a temp variable (as its not being stored in a table) comes with a text limit? Is there anyway to extend this?

Cheers

View 9 Replies View Related

Referencing A Variable

Apr 6, 2008

I want to be able to reference a variable dependant on where I am within a loop. I have myct1, myct2 and myct3 looping then a mycount loop and I want to add a record to a table taking the relevant myct value dependanct on the current mycount value. Any ideas anyone?

Here is my code:

for myct1 = 1 to 3

for myct2 = 1 to 3

for myct3 = 1 to 3

for mycount = 1 to 3

mytable.addnew
myvalue = <if mycount = 1 then myct1 etc>
mytable.update

next mycount

next myct3

next myct2

next myct1

Any help most appreciated.

View 1 Replies View Related







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