Solved

Query in access 97

Posted on 1998-08-29
18
216 Views
Last Modified: 2011-10-03
i have a MY_T table which has 3 fields: F_1,F_2,F_3
i want(with code) to get the values of F_2,F_3 (where F_1 equalls to a number X).
how can i do it?
0
Comment
Question by:rzvika2
  • 10
  • 8
18 Comments
 
LVL 2

Accepted Solution

by:
mkmccreary earned 10 total points
ID: 1960634
Here is some code to do it, I haven't tested it.  I assumed that X was a numeric value.  If it is a string you need to enclose the value in single quotes in the string, and if it is a date it needs to be enclosed within number signs(#).

Dim rsRecords as Recordset
Dim sSQL as String
Dim X as Long

sSQL = "Select F_2, F_3 From MY_T Where F_1 = " & X & ";"
Set rsRecords = DBEngine.Workspaces(0).OpenRecordset(sSQL)
If Not rsRecords.BOF And Not rsRecords.EOF Then
     'There are some records to process
     rsRecords.MoveFirst
     While Not rsRecords.EOF
          ' Process Your Records Here
     Wend
End If
rsRecords.Close
Set rsRecords = Nothing


0
 

Author Comment

by:rzvika2
ID: 1960635
it says:"method or data member not found"
about the: ".OpenRecordset" in the line:
Set rsRecords = DBEngine.Workspaces(0).OpenRecordset(sSQL)

0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960636
Sorry,
    A little syntax error there.  The line should read

    Set rsRecords = DBEngine.Workspaces(0).Databases(0).OpenRecordset(sSQL)

Try this and see if it work.

Martin
0
 

Author Comment

by:rzvika2
ID: 1960637
well, the final cade(that the access was agree to do)is as followed:

    sSQL = "SELECT T_DefaultSpecialAngles.CodeAngle,    T_DefaultSpecialAngles.DegreeAngle, T_DefaultSpecialAngles.Convert FROM T_DefaultSpecialAngles Where T_DefaultSpecialAngles.CodeAngle = " & CAngle & ";"
    Set rsRecords = DBEngine.Workspaces(0).Databases(0).OpenRecordset(sSQL)
    If Not rsRecords.BOF And Not rsRecords.EOF Then
         rsRecords.MoveFirst
         While Not rsRecords.EOF
            a = rsRecords!Convert
            b = rsRecords!DegreeAngle
            c = rsRecords!CodeAngle
            rsRecords.MoveNext
         Wend
    End If
    rsRecords.Close
    Set rsRecords = Nothing

(the only missed thing was the  "rsRecords.MoveNext")
thank you!
(by the way, if you tell me the actions that i have to do in order to play wave and avi files by access, i'll give you more 40 points).
and thank you again.

0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960638
Here you go.  If in Access 97 open the form you wish to play the files from in design mode.  You then need to use the Insert menu and select ActiveX Controls.  Select the 'Microsoft MCI Control'.  You then need to add the below code from where you want the playing to occur:


    ' Initialize the control
    MMControl1.Visible = False
    MMControl1.Enabled = False
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
   
    ' Play a wave file
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.Filename = "D:\WINNT\Media\chimes.WAV"
    MMControl1.Command = "Open"
    MMControl1.Wait = True
    MMControl1.Command = "Play"
    MMControl1.Command = "Close"
   
    ' Play an AVI file
    MMControl1.DeviceType = "AVIVideo"
    MMControl1.Filename = "D:\WINNT\clock.avi"
    MMControl1.Command = "Open"
    MMControl1.Wait = True
    MMControl1.Command = "Play"
    MMControl1.Command = "Close"
 
You may want to hide the control in the form load event, or you may want to allow the user to control the play, it is up to you.  I hope this helps you out.

Later,
Martin

0
 

Author Comment

by:rzvika2
ID: 1960639
thank you mkmccreary or Martin.
i dont have the option of upgrade the points, so tell me what or where to ask you this question again so that i could give you what i prommised.
btw, i didn't try it but if i have questions i will ask you again. thank you very much.
0
 

Author Comment

by:rzvika2
ID: 1960640
when i insert the  Microsoft Music Control it says:
"the operation on the ole object failed
the ole server may not be registered"
what sould i do?
thank you again!
0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960641
I try to insert the Music control and get the same error, but there is a good side, we don't want to use this control.  We want to use the Microsoft Multimedia Control.  

Hope It Helps,
Martin

0
 

Author Comment

by:rzvika2
ID: 1960642
i dont have Microsoft Multimedia Control (what is its exact name?) and how can i install it , if necesary?
and by the way, if i want to play a wave or avi, and i don't want a control like in the compact disc(play , forward etc...)do i have to put that activeX anyway?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960643
Try this code and see if it works.  It is Dim-ing a control of type MMControl which I use to play the files.  I placed this code under a command button to test it.  You will also have to change the filenames to valid files.  Try this:

Dim MMControl1 As New MMControl

    ' Initialize the control
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
     
    ' Play a wave file
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.FileName = "c:\WINNT\Media\chimes.WAV"
    MMControl1.Command = "Open"
    MMControl1.Wait = True
    MMControl1.Command = "Play"
    MMControl1.Command = "Close"
     
    ' Play an AVI file
    MMControl1.DeviceType = "AVIVideo"
    MMControl1.FileName = "c:\WINNT\clock.avi"
    MMControl1.Command = "Open"
    MMControl1.Wait = True
    MMControl1.Command = "Play"
    MMControl1.Command = "Close"

Set MMControl1 = Nothing

Just Drop Me A note and let me know how it works.

0
 

Author Comment

by:rzvika2
ID: 1960644
it doesn't know the MMcontrol .
i installed the whole office.
when i try to search in help about the MMcontrol, it doesn't find anything.
0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960645
I figured out that the multimedia control does not ship with Office97, it ships with certain versions of VB as well as the Office Developers Addition.  I have found an article on how to do it with API calls.  The article is on Microsofts homepage at http://www.microsoft.com/accessdev/articles/movies.htm.  It covers both .AVI and .WAV files.  I didn't have time to read the whole article.

Good Luck,
Martin

0
 

Author Comment

by:rzvika2
ID: 1960646
hate to waste your time, thank you for keeping answering me!
now:
if i have the developer edition, it will be ok?
second, if i have the vb5 installed on my computer, this should work? should i do something special?(in the installation stage)?
thank you anyway.

0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960647
It should be ok if you have the Developer's Addition or VB5 on your computer.  I didn't have to register the controls in Access, they were just there when I went to access them.  You may have to go to the Tools - ActiveX Controls menu option and select the register button to find and register the control.  Bye the way the name of the control is MCI32.OCX.

Hope this helps,
Martin

P/S  I'm not sure which versions of VB include the MCI32.OCX control.
0
 

Author Comment

by:rzvika2
ID: 1960648
mkmccreary:
TTTTTTAAAAAAAAANNNNNNNNNNKKKKKKKKKK you!!!
i went to : "http://www.microsoft.com/accessdev/articles/movies.htm"
and the actually put a word file with an access aplication that demonstrate what i wanted!!!
now tell me how can i give you more 40 pointes!
thank you again!!!
zvi.
0
 

Author Comment

by:rzvika2
ID: 1960649
can you help me with playing wav files in java applications?
it is quite urgent and i haven't got answer about this(the answers was about applets).

0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1960650
Sorry,
    No Java experience at this time.  I guess you could post a question and just put in the title for me only.  I don't know.  I just started playing last week.  I'm glad I was able to help you out.

Later,
Martin

0
 

Author Comment

by:rzvika2
ID: 1960651
mkmccreary, how can i ask you (and only you) a question ?
in any case, i asked a question about the details in a report.
if you could answer it, i will be very glad!
by
zvi.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now