Run a second query on 1 Subform (1 Viewer)

Surka

IT dude
Local time
Today, 03:29
Joined
Aug 5, 2013
Messages
41
Working with the attached mdb.

I am trying to search inside the subform.

First you should search for a "user", e g: a
on the second textbox, for a serial number: m1

Using a second query, I would like to search the input from the secondbox (Like I did with the first textbox).

Problem is that at the properties of the subform1 I was able to assign only one Source.

How can I add a second one? So it runs the second Query too.

THanks,

Surka.
 

Attachments

  • database - 2 query 1 subform 2 tables.accdb
    548 KB · Views: 59

Cronk

Registered User.
Local time
Today, 16:29
Joined
Jul 4, 2013
Messages
2,772
Firstly, let's get your table structure reflecting what you really want.

Is your table Telephone a list of telephone numbers assigned to users? I'd suggest it should be called tblUsers with the fields UserID, UserName, Telephone.

Then you have Monitor. Is that an event that a user is monitoring? In which case the table should be EventID (or SituationID or whatever), UserID, EventName.

Fix that and re-post.
 

Surka

IT dude
Local time
Today, 03:29
Joined
Aug 5, 2013
Messages
41
Thanks Cronk. It is a stock inventory. IP Telephones (with users and sn of the telephone this user has assigned), and computer monitors (LCD)
 

JHB

Have been here a while
Local time
Today, 08:29
Joined
Jun 17, 2012
Messages
7,732
I'm a little unsure what you really want, but try the attached database.
 

Attachments

  • database - 2 query 1 subform 2 tables-11.accdb
    572 KB · Views: 67

Surka

IT dude
Local time
Today, 03:29
Joined
Aug 5, 2013
Messages
41
You did understand. At least it does what I need. Could you explain it to me?

I do not understand the following:
Code:
SELECT ALL Monitor.User, "Monitor" AS Devices, Monitor.Serial
FROM Monitor
WHERE Monitor.User = [Forms]![Form1]![txtUser] and (Serial=[Forms]![Form1]![txtSerial] or [Forms]![Form1]![txtSerial] is null)  ;

It does not seem to search inside the subform.

It will get data where txtUser==Monitor.User, and where Monitor.Serial==txtSerial?Also, why there is no need of putting Monitor.Serial? You put Serial=

WAIT! My question is, why it searches on the results? how did you accomplish that?

Thanks!
 
Last edited:

JHB

Have been here a while
Local time
Today, 08:29
Joined
Jun 17, 2012
Messages
7,732
WAIT! My question is, why it searches on the results? how did you accomplish that?

Thanks!
No it is not searching on the results!
I change the query to use 2 criteria instead of one.

The second criteria is more or less so: If something filled in the control [txtSerial] on the form then search after the value, (else ignore it).

By the way, did you read my signature? :)
 

Surka

IT dude
Local time
Today, 03:29
Joined
Aug 5, 2013
Messages
41
And why the results are from the user searched before and not from every user?
Thanks.
 

JHB

Have been here a while
Local time
Today, 08:29
Joined
Jun 17, 2012
Messages
7,732
You can use so many criteria in a query as you like, (or as many as MS-Access accept), to be get a result they all need to true, you don't need to query for each single criteria.
 

Surka

IT dude
Local time
Today, 03:29
Joined
Aug 5, 2013
Messages
41
:banghead:My bad , now I read the query again and understood it. WHERE statement with the AND is the key. It searches for data which is ok with both conditions (txtSerial and txtUser).

Thanks!
 

Users who are viewing this thread

Top Bottom