Solved Form_Load() question (1 Viewer)

mloucel

Member
Local time
Today, 04:05
Joined
Aug 5, 2020
Messages
153
I have a split database [FE] and [BE]
I added a new table that contains only 1 record, ID and OfficeName

my users FIRST need to go thru a Login Screen.
I need on the Form_Load [Event] of the login screen to look for that 1 record and do something like this:

me.lblOffLocation.caption=OfficeName
or alternative:
TempVars("OfficeName").value=[OfficeName]

I try using a Dlookup:
Me.lblOfficeLocation.Caption = DLookup("OfficeLocation", "Offices", "Office_ID = " & [Office_Id]) & ""
but returns an error since of course there is no data in Office_ID, [it works if I change [Office_ID] to 1, or 2, or 3, or 4, or 5, etc.]

So how can I do it, what am I missing? I would love to put that in a TempVars location, it will make my life easier.
but how can I do it from Form_Load without no data input, just somehow open the Offices database, get that 1 record, move the OfficeName to a TempVar and use it all over the code.

Any Help will be very appreciated.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:05
Joined
May 21, 2018
Messages
8,529
I am confused. You have a "new table" what is that called? Where is the new table located (FE/BE)? Is this table different than table "Offices"? Table Offices looks like it has more than one record?
I am not sure what table Offices has to do with this. I would think it would be pulling the office name out of the new table with one record and no need for a criteria.
dlookup("OfficeName","NewTableWithOneRecord")
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:05
Joined
Apr 27, 2015
Messages
6,341
If the table only holds one record (by design), why not simply bind the form to the OfficeLocation table?
 

mloucel

Member
Local time
Today, 04:05
Joined
Aug 5, 2020
Messages
153
I am confused. You have a "new table" what is that called? Where is the new table located (FE/BE)? Is this table different than table "Offices"? Table Offices looks like it has more than one record?
I am not sure what table Offices has to do with this. I would think it would be pulling the office name out of the new table with one record and no need for a criteria.
dlookup("OfficeName","NewTableWithOneRecord")
I'm sorry the new table is called Offices, just a name, and all tables are always BE, they cannot be FE.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:05
Joined
Feb 28, 2001
Messages
27,186
Somehow I get the impression that you haven't explained something.

Why do you care about the OfficeName and its ID? More specifically, what functionality does it support? Are you suggesting that you need to know the Office ID in order to support an office-specific login process?

Generally, if you have a domain-based network, there are things you can ask of that domain controller to tell you who is logged in for that computer (with respect to a domain ID). While environment variables can be spoofed, domain information is more reliable.

I see one possibility - that if you have predictability of who is using which machine, you can look up the hardware machine serial number or hardware primary disk serial number. That could also lead to some kind of hint for your login ID.

Therefore, explain your actual goal with the question WITHOUT delving into code. Tell us PURPOSE.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:05
Joined
May 21, 2018
Messages
8,529
I added a new table that contains only 1 record, ID and OfficeName
I'm sorry the new table is called Offices
Me.lblOfficeLocation.Caption = DLookup("OfficeLocation", "Offices", "Office_ID = " & [Office_Id]) & ""
but returns an error since of course there is no data in Office_ID, [it works if I change [Office_ID] to 1, or 2, or 3, or 4, or 5, etc

Something is not possible. Your table called Offices has only one record, but in your dlookup you say you can return at least 5 or more different records.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:05
Joined
Jan 23, 2006
Messages
15,379
We need more info about your process to be supported and clear info on what code you have.
Readers are not understanding your requirement, nor your current code.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:05
Joined
Sep 21, 2011
Messages
14,304
because the form by design must not be bind to any table.
So change the design. :( Nothing is written in stone.
The controls can be hidden if it is a login form.
In my login forms, I sometimes had to ask what company they were working in.
 

mloucel

Member
Local time
Today, 04:05
Joined
Aug 5, 2020
Messages
153
So change the design. :( Nothing is written in stone.
The controls can be hidden if it is a login form.
In my login forms, I sometimes had to ask what company they were working in.
Exactly what I did.. Since the Table is different in each office, I just added the field without the need to set the record source to a table, so it doesn't matter which office I replace the front end, it will always work.
I thought using dlookup was going to be my solution but it was easier this way.
Sorry about all the fuzz.
 

Users who are viewing this thread

Top Bottom