Modules & VBA :: Random Songs On A Form With Media Player Embedded
Nov 21, 2014
I have a form with windows media player embedded in it. What I want it to do is play a random song when I open it. So I put a field called Randomizer in the form and added this code.
Me.randomizer.Value = Int((60 - 1 + 1) * Rnd + 1)
Now How do I put the URL for the song into vba format? I tried just using the URL property field for the player (D:[randomizer].mp3) but no luck.
I have a form with an ActiveX Control for Media Player 10. The player works ok, but if I try to close the form using the PlayStateChange Event, Access crashes out to the 'Send Report To Microsoft' window.
This is the code:-
Private Sub WindowsMediaPlayer0_PlayStateChange(ByVal Newstate As Long)
If Newstate = 8 Then
DoCmd.Close
End If End Sub
This is looking for the end of the current media file, but I get the same problem if I look for Newstate = 1, the stop button being pressed.
However, if I put the DoCmd.Close command behind a command button, the form closes as normal.
After searching the forums, I've found some information, but not what I need or what works.
I've got everything playing fine, from where people can play a file they choose from a list, but I need to add some advanced controls for Fast Fowarding and such.
Searching google, I've managed to find plenty of VB controls, but none seem to work in VBA. I've set the Media Player references, but when trying:
me.MediaPlayer0.Controls the only option it gives me are Items and Count, not Play, Stop or Pause (or anything similar).
I want to have a MS Access 2000 database open, load a Form with various option buttons on and get Windows Media Player to play a MP3 music file. However, when I click a option button on the Form I want the music to stop.
I'm working on a database for my holiday pictures. The pictures are organized in folders per trip/date/location.
When viewing the data of a particular trip, I want the form to display a random image from the respective folder (path stored in database).
I already found a function to count the files in the folder:
Code: Function GetFileCount(folderspec As String) As Integer ' Returns a count of files in folderspec, or -1 if folder does not exist Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") If fso.FolderExists(folderspec) Then GetFileCount = fso.GetFolder(folderspec).Files.Count Else GetFileCount = -1 End If End Function
I already created pages that with checkboxes that user select indvidual songs and by click of play button it goes and plays those songs for me.
Now i created another button next to play that it supposed to write the selected songs to db and save the ids of slected songs.Note: i use song ids to pull indvidual songs from db to be played by my song player!
My problem is i do not how to design a few tables that keep track of selected songs for each user along with the name of playlist for each user!! In processs i do not want to modify my current table i just want to add more tables to help me achive what i want. I be happy if an expert tell me how i can create tables that store play list(selected songs)info for each user and later i be able to query them easily in order to pull out playlist of each user.Thanks
I need to replace the embedded image on a large number of reports and forms. I'm looking for a way to loop through all of the controls in my forms and reports and if the control is an image, replace the embedded image with a new one. Can this be done using vba?
I'm using ACCESS 2010. I have a form which is having a embedded word document. What I'm trying to do is i want to enable user to format a mail in the embedded word document which will contain rich text and screenshots then with a click of button an outlook mail should open and content of this document should be pasted there. Once user sends this email, I want to save content of embedded document in the database.
I have code that automatically send emails out from an Access Customer Contacts Database. I am using Access and Outlook 2007 but the code needs to work with later versions of Access and Outlook.
I have very poor knowledge of coding and usually manage to cobble something together from looking at other code on the net but don't understand most of it.
I have the following code which works perfectly except I want to be able to embed an image in the email body (not have the image as an attachment but actually show it in the body of the email).
Most of the code I have found around this topic is too complex for me to understand and utilise within the context of the code I have.
Ideally I want to take the image from an attachment field in a table returned by the "tblMailingList_Query".
Code: Private Sub Command10_Click() Dim MyDB As Database Dim MyRS As Recordset Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem
I have a log in screen that my users must use before they can use my db. if they enter the wrong username/password they get the usual message boxes. I also thought it would be a nice personal touch if once they've logged in they get a little greeting, so i made a message box that says "Hello " followed by their first name
This did the trick for a while, however theyre sick of seeing "Hello" and want other greetings, i figured this wouldnt be too complicated and took me only about 10 minutes or so to implement.
Basically i created a table (tblGreetings), has two fields, an autonumber field (ID) and a short text field
I've added the following code into the login sequence:
Dim greetings As Integer Dim greet As String Dim randomNum greetings = DCount("ID", "tblGreetings") randomNum= Int((greetings - 1 + 1) * Rnd + 1) greet = DLookup("Greeting", "tblGreetings", "[ID]=" & randomNum)
which in theory should generate a random number between 1 and "greetings" (which is an integer representing the number of greetings ive stored in my table), currently greetings=9
then it should pick a greeting from tblGreetings using the random number as an ID
This more or less works, except whenever the DB is opened and a user logs in, the "random" number is the same every time, it always seems to be 7 (which corresponds to the greeting "G'day").
Why this random number is always the same? it changes if i run the code a few times in the same session, but once the database is closed and reopened it still gives off the number 7, every time
I thought this would be pretty simple, but I cannot figure out how and wasn't able find the solution here or anyway.
I have a source form. (I can resort to having a Table with OLE Object if I must, but prefer not to.) On this source form I wish to include different things such as company logo. This will determine what logo shows up in all the reports, so all the reports will have an image linking back to this embedded image on the source form.
Pseudo-code Example: frmSource contains imgLogo rptSample contains an image whose control source = Forms!frmSource!imgLogo
How can I do this or achieve the same effect in a more-or-less simple way?
I am using a API to generate a random / unique directory. This an API form a 32-bits environment.
I know that you can still use it when declaring it with PtrSafe
This is the code I am using:
Option Compare Database Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
I have a RN generator that looks at 9 different lanes and puts in a number based off of a certain criteria but I was wondering if in the frmLanes the actual "Go" button was an incoming number how could I get my current random number generator to look at that number and determine if the current number is within 5 of the "go" number?
Any way to have a beginning number that I would enter into a text box and have the number generator kick off based off of that number. I have included a copy of my db for viewing.
I'm having trouble with my VBA module.I have a random test generator which pulls records based on a category from my table into a temp table using a make table query. I use the following code:
Private Sub Command2_Click() DoCmd.SetWarnings False DoCmd.OpenQuery "1", acViewNormal, acEdit DoCmd.OpenReport "WrittenExam", acViewPreview, "", "", acNormal Reports!WrittenExam.lblTitle.Caption = "Exam Name" DoCmd.OpenReport "WrittenExamAnswerSheet", acViewPreview, "", "", acNormal Reports!WrittenExamAnswerSheets.lblTitle.Caption = "Exam Name - Answer Sheet" End Sub
My querry makes the table, and then generates two reports (my exam, and the answer sheet). I'm getting an error 3211, saying the temp table is already in use by another process when trying to generate both reports. I used a Macro before, but I have a need for custom report headings, so I'm using VBA.
random image selection from a form on a buton click event.To be more explicit: i have 7 images on form, when i push one buton i want to see how each image take focus (when take focus .BorderColor =vbRed after lose focus .BorderColor =vbWhite) and after lets say 20s focus stop random on one image and keep that image with .BorderColor =vbRed.
I have an access form with tab control pages each with embedded forms.In one page I have a list of records as a datasheet form with the record identifier field configured as a hyperlink. When I click on this it passes its value to a form field in the form in the following tab page (works without the hyperlink but its a useful way of highlighting which field to click) which is a display/edit form of the details of the individual record. The Subroutine which does this sets the focus on this field it is passing the value to on the other form and the 'On Got Focus' event in that triggers the query that fills the editor form.
When I click back on the following tab to select another record to view/edit, the identifier value of the other record is passed to the other form but the data displayed in the rest form doesn't change. I understand this is because the field with the 'On Got Focus' never lost focus and so the query function was not called. To correct this I tried adding the same function call to the 'On Change' event however this does not work (the field is a text box set to 'locked' if that is relevant).I can get the form to do a new query properly if I click on a different field in the form before going back to the list tab or (as this is removing the focus allowing the On Got Focus to work again) if I click on a button to select a different record (which just takes me back to the list form).
Is there any way I can get this to work without having to manually remove the focus from the problem field? I have tried setting its On Got Focus event to move the focus to another field after the query function call however this prevents the Setfocus line in the code in the previous form from working. Here is a snippet of my code below.This code is for the list form and passes a value to the editing form:
I am needing to develop an audio catalog and would like to know if anyone has experience with embedding audio in an Access database. The ideal situation would be to have all audio contained within the database, however, some of the audio files may be quite large and I don't want to bog down the entire database by having 100MB files in there either.
So I guess my question simply is; if my audio files are 50MB or larger, embed or link?
In the form view of the db I have a bound box for an embedded ole object I use it to embed Word documents for each db entry (The database is for works of art and the Word document is the description of each work of art which often contains Chinese Characters, hence the Word Document)
The box is set to show an icon (The Word Icon) Upon entering the data and moving off the record, subsequent return to to the record sometimes shows that the icon is gone from the box, it is blank. Clicking the blank box brings up the Word Document but then closing the Word Document and re-clicking the blank box dos not bring up the Word Document. The standard message saying that the ole object is empty appears and all the data from the Word Document is lost.
this has only happened since moving to Office 2007. I upgraded the db to 2007 format and we are using Word 2007.
A Google of the symptoms doesn't bring any meaningful results, does anyone have any ideas?
I tried to keep this as short as possible (which wasn't easy) if you need more info just ask
I have an embedded excel workbook on an Access form (Access 2002)
I would like to change the zoom of the excel "view".
I've tried this:
' xlCharts is an embedded XL workbook xlCharts.Object.Parent.ActiveWindow.Zoom = 100 I get an error that says: "Unable to set the Zoom property of the Window class"
However, if I READ the zoom level, it works fine. The zoom property of the window class in excel is read/write, but this may not be the case for embedded OLE objects. Is there another way? Does anyone have any ideas?
Ok, say I have a table with the following fields, custid, mainnum, subnum whereas the data would look like this: Code:Cust Main SubA101 1 2A101 2 1A101 3 4A101 4 2A101 5 3B202 1 2B202 2 4B202 3 1C303 1 2C303 2 1
The main number always counts up from 1 on each new customer, I already have code to do this. I am running a for next loop based on the highest main number (I already have this part), for instance, for Cust A101, the for next loop would essentially be: for x = 1 to 5.... like I said, I have this part.
What I want to do when x is counting, to pull up the mainnum value that equals the value in the for/next (in other words equals X), and run a for next loop based on the sub number based for that record. For example using C303's data: Code:For X = 1 to MaxOfMainNum '<---I already have this 'code to pull up subnum where mainnum=X For Y=1 to SubNum_For_Selected_Mainnum 'I will be doing an insert to table here custid,x,y Next YNext X The parts in Bold in the above code is what I'm needing an answer to.
I tried to be as concise as possible, but I know it might be confusing.
I have a form with a calculated time difference between a "Start" and "Stop" time I have managed to get the correct formula however I would like to display this value in a more civilized forma as HH:MM on the example attached I have some values that appear as 4:8 and it should be 04:08.
The second problem is I need to embed this calculated value on my tblTime as doing so I can run more easily some queries.
pretty Excel sheet full of conditional formatting that is used as a vehicle assignment board where I work. I know I can embed the file into an Access form using an unbound object, and therefore "integrate" it into Access, however this creates a copy of the file, and therefore when people change the sheet, the original Excel file is not updated. Is there any way to embed the excel file in such a way that the Excel document itself is also updated? Basically some sort of an active, two-way link rather than what amounts to just importing a copy of it? I need to be able to pull data from various cells in that Excel file so it needs to be kept up-to-date.
I would like to know if it is possible in Access 2007 to add a button/hyperlink where by the order number (as in the example below) is being sourced from another field [ORDNR]
i.e. replacing the 0996653 for example with a lookup to the ordernumber held in another column?!
[URL] .....
this link is one from a web url - I want to copy this in my DB.