Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 7th, 2008, 08:36 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
Selecting Records

Didnt know what to title this one....

In a bit of a mind block here on how I want to tackle this one.
What I am looking for is a way to create a query based on Field Name and the Unique Attributes resulting in a count.

Say I have Three fields in a table (field1 field2 field3)
I want a drop down that shows the three fields
WHen the user selects one a query is run populating another drop down with the Unique values from that field.
The user then selects a unique value from the second drop down box and it runs another query that gives the user a total count of occurances of that attribute in the db.

So I choose "Type" Field
In the second dropdown box the unique values for that fields are (Accident, Fire, Robbery)
I choose Fire
In the textbox the resulting number of fire records shows up

There are currently 25 fire related instances in the database


The thing is that the user can then change the query and query another field with different attributes....

That make sense....

Just looking for a little guidance on logic here....any help woudl be appreciated....

Reply With Quote
  #2  
Old May 7th, 2008, 08:48 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
I think I might be getting somewhere...

I have this: Just trying to figure out how to populate the second dropdown box with the values from the query...

Thoughts?

Am I on the right path???

ALTHOUGH it appears I again have soem syntax issues with the SQL String...help?


Code:
Private Sub Combo89_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim varFieldType As String
varFieldType = Combo85
MsgBox varFieldType

Dim MySQL As String
MySQL = ""
MySQL = "SELECT dbo_Core2.'" & varFieldType & "' FROM dbo_Core2 GROUP BY dbo_Core2.'" & varFieldType & "';"

MsgBox MySQL

End Sub

Last edited by Jaykappy : May 7th, 2008 at 08:50 AM.

Reply With Quote
  #3  
Old May 7th, 2008, 08:48 AM
rpeare rpeare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2008
Posts: 817 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 6 Days 3 h 31 m 27 sec
Reputation Power: 172
If you've got your selection criteria form set up (sounds like you're using combo boxes)

All you have to do is build a query that shows all your information then in the criteria section just use things like

[forms]![yourformname]![yourfieldname1]
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #4  
Old May 7th, 2008, 08:53 AM
rpeare rpeare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2008
Posts: 817 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 6 Days 3 h 31 m 27 sec
Reputation Power: 172
Hang on a tic. Are you trying to pick a specific field and build your query based on the field they pick and apply some criteria to that field or are you looking at a static field list and applying criteria to that list?

For instance let's say you have the following table:

Tbl_Example
Code:
PersonID  ServDate  Cost
1         1/1/2008  20.00
1         2/1/2008  40.00
2         3/1/2008  20.00


Are you trying to build a mechanism to build a query based on any of the three columns of data and apply a criteria to that column OR are you taking the whole table and trying to apply criteria to one or more of those columns?

Reply With Quote
  #5  
Old May 7th, 2008, 09:18 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
PersonID ServDate Cost
1 1/1/2008 20.00
1 2/1/2008 40.00
2 3/1/2008 20.00


First Drop down lists (PersonID, ServDate, Cost) (Hardcoded to the dropdown box

Second Dropdown will run a query that grabs the field name and populates the second dropdown with all the unique values

When that is choosen a second query will run calculating how many unique instances (records) there are in the database.

So I choose ServDate in the 1st dropdown
When I click the second Dropdown it will have bee populated with the three dates above
After I choose say "3/1/2008"
A Textbox will give me a number (1) in this case for the single occurance

ServDate of 3/1/2008 results in 1 record

This query will allow the user to tally how many of a particular robberies for example are in the database...

My above code I think is getting me close...I am taking the Field value from the 1st dropdown...and trying to fit that into a query that will get the unique values....then just need to push them to the 2nd Dropdown box...

Last edited by Jaykappy : May 7th, 2008 at 09:20 AM.

Reply With Quote
  #6  
Old May 7th, 2008, 09:21 AM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,624 sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Weeks 11 h 35 m 12 sec
Reputation Power: 1294
I think dlookup is what you're looking for.

The syntax in vba is:

YourField = dlookup("[Field2Return]"), "TableOrQueryName", "CriteriaField = " & me.Value)

Which does this:
Code:
SELECT Field2Return AS Expr1
FROM [TableOrQueryName]
WHERE ((([TableOrQueryName].CriteriaField)=me.value));


The criteria is optional.
__________________
Did I help you? If so gimme rep by clicking on the at the top right corner of this post

Madness does not always howl. Sometimes, it is the quiet voice at the end of the day saying, "Hey, is there room in your head for one more?"


Last edited by sbenj69 : May 7th, 2008 at 09:45 AM. Reason: forgot an ampersand

Reply With Quote
  #7  
Old May 7th, 2008, 09:23 AM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,624 sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Weeks 11 h 35 m 12 sec
Reputation Power: 1294
oops, I didn't see your most recent post as I was typing mine

Reply With Quote
  #8  
Old May 7th, 2008, 09:37 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
I tried this

MySQL = dlookup("[varFieldType]"), "dbo_Core2", "CriteriaField = " me.Value)

Getting an error....is there a "(" missing from right after dlookup....I add it then get another error?

What is the Me.Value?

THANK YOU VERY MUCH rpeare....


Code:
Dim varFieldType As String
varFieldType = Combo85

Dim MySQL As String

MySQL = dlookup("[varFieldType]", "dbo_Core2",)

Last edited by Jaykappy : May 7th, 2008 at 09:40 AM.

Reply With Quote
  #9  
Old May 7th, 2008, 09:44 AM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,624 sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)sbenj69 User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1Folding Points: 270723 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Weeks 11 h 35 m 12 sec
Reputation Power: 1294
put an & sign by me.value. Criteriafield also has to be a field in your query/table

Reply With Quote
  #10  
Old May 7th, 2008, 09:53 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
Combo85 is the Field Dropdown that determines the field name to base the query on. I set this to a varaible "varFieldType"

It is saying:

Compile Error:
Method or Data Member not found


AND HIGHLIGHTS Me.Value




Code:
Dim varFieldType As String
varFieldType = Combo85

Dim MySQL As String

MySQL = DLookup("[varFieldType]", "dbo_Core2", "[varFieldType] = " & Me.Value)

MsgBox MySQL

Reply With Quote
  #11  
Old May 7th, 2008, 10:01 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
Are we on the same page here...dotn know.

The code I am writing is on the Mouse Down of the Second Drop down....
I already choose the Field Name in the first dropdown....

I am getting the name from the Variable varFieldType when I click the second Dropdown

Now I am trying to get all the unique values from that Field and place them in the textbox I just clicked.

Thanks rpeare

Reply With Quote
  #12  
Old May 7th, 2008, 12:18 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 711 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 5 h 27 m 10 sec
Reputation Power: 22
OK I see whats going on here..

but I dont have a Field and value to look for...

I want to choose a field (from the 1st dropdown box) and populate a drop down box with ALL the unique values from that field...

So if there are 200 unique values in the "Status" field I want to place all those in the second combobox.

So I choose Status in the First Box
When I click the second combobox I need a query to populate the second box with all these unique values.

The the user can select a attribute from that specific field...


Then I can run a query to calculate sums etc...

Reply With Quote
  #13  
Old May 7th, 2008, 12:52 PM
rpeare rpeare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2008
Posts: 817 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 6 Days 3 h 31 m 27 sec
Reputation Power: 172
never tried to do this before I'll try to figure it out when I get home this evening.

Reply With Quote