• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Query in access 97

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
rzvika2
Asked:
rzvika2
  • 10
  • 8
1 Solution
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
it says:"method or data member not found"
about the: ".OpenRecordset" in the line:
Set rsRecords = DBEngine.Workspaces(0).OpenRecordset(sSQL)

0
 
mkmccrearyCommented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
 
rzvika2Author Commented:
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
 
mkmccrearyCommented:
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
 
rzvika2Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 10
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now