473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access SQL

Hi,
I am kind of new at Access (pretty good with VBA I think :). I am
trying to retrieve data using SQL statement. I have a table with 5
field: ID (Access given), Card1, Card2, Group, Point.
I want to see other values based on Card1 and Card2. I think I can get
record with OpenRecordSet. I can print Count on that object and returns
1 (I think it should be). But i don't know how to use them. I tried
!Group but it is giving me error (I did with .FindFirst but it only
filter by one condition not multiple one) I got code:

Private Sub Card1_AfterUpdate()
Dim lsCard1 As String
Dim lsCard2 As String
Dim mySQL As String
Dim loDB As DAO.Database
Dim loRSPlayer As DAO.Recordset
Set loDB = CurrentDb()

lsCard1 = Card1.ItemData(Card1.ListIndex)
lsCard2 = Card2.ItemData(Card2.ListIndex)
'Get SQL
mySQL = "SELECT HandGroup.[Group] from HandGroup where Card1 = " &
lsCard1 _
& " AND Card2 = " & lsCard2

Set loRSPlayer = loDB.OpenRecordset(mySQL)

If Not loRSPlayer.EOF Then Me.Bookmark = loRSPlayer.Bookmark
End Sub
Thx

May 30 '06 #1
3 2040
pe****@syr.edu wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
I am kind of new at Access (pretty good with VBA I think :). I am
trying to retrieve data using SQL statement. I have a table with 5
field: ID (Access given), Card1, Card2, Group, Point.
I want to see other values based on Card1 and Card2. I think I can
get record with OpenRecordSet. I can print Count on that object
and returns 1 (I think it should be). But i don't know how to use
them. I tried !Group but it is giving me error (I did with
.FindFirst but it only filter by one condition not multiple one)
I got code:


I don't understand what the point of the recordset is or where
you're using this. Is it in a form? If so, then create a filter that
filters the form, then you can browse the records that match the
filter. You may find the IN ([sql]) operator useful, as it will
leave the recordset of the form editable.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
May 30 '06 #2

David W. Fenton wrote:
pe****@syr.edu wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
I am kind of new at Access (pretty good with VBA I think :). I am
trying to retrieve data using SQL statement. I have a table with 5
field: ID (Access given), Card1, Card2, Group, Point.
I want to see other values based on Card1 and Card2. I think I can
get record with OpenRecordSet. I can print Count on that object
and returns 1 (I think it should be). But i don't know how to use
them. I tried !Group but it is giving me error (I did with
.FindFirst but it only filter by one condition not multiple one)
I got code:


I don't understand what the point of the recordset is or where
you're using this. Is it in a form? If so, then create a filter that
filters the form, then you can browse the records that match the
filter. You may find the IN ([sql]) operator useful, as it will
leave the recordset of the form editable.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/


Could you please let me know how to do that? I want to do that in VBA
since I got 2 comboboxes setting that filter. ANd also how can I access
that record? FindFirst?

Thx

May 31 '06 #3
pe****@syr.edu wrote in
news:11**********************@g10g2000cwb.googlegr oups.com:

David W. Fenton wrote:
pe****@syr.edu wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
> I am kind of new at Access (pretty good with VBA I think :). I
> am trying to retrieve data using SQL statement. I have a table
> with 5 field: ID (Access given), Card1, Card2, Group, Point.
> I want to see other values based on Card1 and Card2. I think I
> can get record with OpenRecordSet. I can print Count on that
> object and returns 1 (I think it should be). But i don't know
> how to use them. I tried !Group but it is giving me error (I
> did with .FindFirst but it only filter by one condition not
> multiple one) I got code:


I don't understand what the point of the recordset is or where
you're using this. Is it in a form? If so, then create a filter
that filters the form, then you can browse the records that match
the filter. You may find the IN ([sql]) operator useful, as it
will leave the recordset of the form editable.


Could you please let me know how to do that? I want to do that in
VBA since I got 2 comboboxes setting that filter. ANd also how can
I access that record? FindFirst?


If it's the form's recordset, you don't have to do anything but use
the navigation buttons in the form.

To filter by two combo boxes, you'll have to have code in the
AfterUpdate events of the combo boxes that check the values of both
of them. Or, you could have a FILTER command button that does it.
You'd then write an appropriate SQL WHERE clause and you can either
change the form's .Recordsource property to the new filtered SQL
statement, or you can set the filter property of the form to the
WHERE clause.

An IN statement would be something like:

SELECT * FROM MyTable
WHERE ID IN (SELECT ID FROM OtherTable WHERE [criteria])

The statement inside the IN () is a full SQL statement returning one
column, the results of which are used as the criteria for the outer
WHERE clause.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.