Modules & VBA :: How To Pause Code When Calling Custom Message Box Form
Feb 9, 2014
I have created a custom message box form that suits my needs for this particular situation. It is called (opened) in the middle of a bunch of other VBA procedures. What I am having a problem with is how do I "pause" the rest of the code from running after the message box call?
For example, with a regular msgbox() function, once called, the code will wait for the user input or click of a button, then continue. My problem is that I am using the basic docmd.openform procedure, and it opens the message box form just fine, but then continues on with the rest of the code after the form is opened.
How would I "pause" the code after the call of opening my custom message box form, then continue it after the user clicks one of my closing buttons from that form?
Furthermore, although its not entirely needed in this situation, for future reference, how would I have that message box form return a value to the calling procedure?
I use the following code for an error message box to pop up. I need to know how bring up a custom form I have made instead of the standard message box but don't know how to code it into the function.
Function StartUp() On Error GoTo Err_ProcedureName
Set db = CurrentDb Set rs = db.OpenRecordset("tblEmployeeBenefits", dbOpenDynaset)
If rs.EOF = False Then rs.MoveLast If rs.Fields("FlagDate") = True Then MsgBox "You need Administrative access for this function to work.", vbOKOnly, "Serious Warning" DoCmd.Quit End If
Else
If rs.BOF = True Then y = 0
Do Until x = 1 x = rs.RecordCount
rs.AddNew rs.Fields("MeDate") = Date + y rs.Update y = y + 1 Loop End If End If UpdateTable
I would like to put a message on the screen for informing the user - mostly during some procedures that might take time or when, after a warning, I want to go on with the program but without action from the user.
Msgbox is obviously not the one I'm looking for as it needs customer acknowledge. Is there a solution for this task?
I am creating an Electronic Medical Records database (well, a fake one, for medical simulation purposes). The way it works, you select a patient from a drop-down on the "Selection" form, and click a command button to bring you to a "Patient information" report. From that report you can view EKG's , Lab results or Imaging reports.This database is to be used for medical simulation for medical students. So for i have command buttons for each report, and a check box to "order tests".
When a test is ordered , i have the command buttons linked to go to a different report that appears the same except it has a subreport with the "new" test results in it. If this were an actual hospital , results would not be instantaneous, so i have the sleep api in for the "on load" for the reports with the "new" results.
I would like it so I could enter how long of a delay i want for the loading of a particular report in the dataentry form i have. But I am not the best at VBA, and I cannot seem to figure out how to get the sleep api to get the value for the number of seconds i want to wait from my table.
I want to call the "On Current" event of another form.
I have a parent(mainform) form and then I have a subform(CurrentForm) and in that subform(CurrentForm) I have another subform(mysubtab01). From the mySubTab01, I want to call the On Current of the parent form. How can i do this?
This is an example of how I am setting the record source of the deepest subform where I want to call the parent on current from:
Forms(mainform)(CurrentForm)(mySubTab01).Form.Reco rdSource = "Select * from subQrytab03"
So Access was unable to manage the amount of content that I needed to produce in a single report. The reports contain 12 charts/graphs all of which I needed on separate pages (one chart per page). As such I could not create large enough charts in access to fit to each page, as Access limits the amount of space one can use in a report.
I downloaded Microsoft Reports Builder 3.0 and built my reports as needed and can generate them as desired at current. I'm wondering if there a way to call that RDL file I created to generate my reports from a form control button in Access?
I have created a database in access with multiple fields.
I have restricted to entering data a specific field with numbers only, but I would like to display a custom error message instead of the default access message. For example: "You can only enter a number in this field" and for another field; you must enter a name in this field if someone tries to ignore a specific field.
I have created a command button through the wizard that is basically: DoCmd.GoToRecord , , acNewRec
Well, it puts all this code in the event:
Private Sub NewVerification_Click() On Error GoTo Err_NewVerification_Click DoCmd.GoToRecord , , acNewRec InboundQuestions!Page1.SetFocus VerificationNo.SetFocus Exit_NewVerification_Click: Exit Sub Err_NewVerification_Click: MsgBox Err.Description Resume Exit_NewVerification_Click
End Sub
Well, my PK field is one users enter in manually (please don't ask why). What I need is something that checks to see if the number in that field is a duplicate key, so I can tell users via msgbox "Duplicate Number, try again". Right now, it's not that descriptive, it says "You can't go to the specified record". I guess all i need is an If statment, but I don't know the code that checks to see if [field1]'s value has already been used in my table. Any ideas?
I have tried the code below, but I am not getting what I need. I have a table [Student Info] with a field [Student ID] as the primary key and many other fields. I added the Student ID field to my form, [Student Add]. When I input an ID that already exists I get an error code as expected but then my form still loads. I currently have a second form for updating student info [Student Update] for which I have a parameter form that asks for the Student ID. I would like to use just one form to add and update students if possible. So, if you add a new Student ID you can enter all pertinent data. However, if you enter a duplicate Student ID the form should populate with that student's information.
If I must have two forms (1 to add and 1 to update) and a duplicate Student ID is entered into the Add form, the user should get a message stating that the record already exists. Then, (Option 1) force the Add form to close without saving or (Option 2) give an option for opening the Update form. Either option is acceptable at this point because I am stuck.
When attempting to use the code below, I get a data mismatch error on the "Answer = DLookUp......" line.
Here's one I use on Social Security numbers for a pop up when a duplicate.... SS# is stored in table "tblApplicant"
Private Sub SocialSecurity_BeforeUpdate(Cancel As Integer) Dim Answer As Variant Answer = DLookup("[SocialSecurity]", "tblApplicant", "[SocialSecurity] = '" & Me.SocialSecurity & "'") If Not IsNull(Answer) Then MsgBox "Duplicate Social Security Number Found" & vbCrLf & "Please enter again.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"
My database has been set with the 'All records' locking option set to prevent two or more people editing files at once. This is working fine but I wondered if there is a way to make a more personal message appear instead of the default Access one, just to maintain a uniform look.
I would like to create a custom pop-up Message when one attempts to add a duplicate record.
Currently, I have a default pop-up message when you try to add a duplicate record. I set the field as Indexed= yes(No Duplicates) which generates a default pop-up message but it is technical and wordy. I would like to be able to simplify the wording to just let the user know not to add a duplicate record.
I have a custom record counter on a form using the below code:
Private Sub Form_Current() If Me.NewRecord Then Me.lblRecordCounter.Caption = _ "Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount + 1 Else Me.lblRecordCounter.Caption = _ "Record " & Me.CurrentRecord & " of " & Me.Recordset.RecordCount End If End Sub
I think at some stage the form was saved with a filter on and this may be causing the issue. The problem I have is:
There are 1749 records. Everytime I open the form the custom record counter displays "Record 1 of 501". The built in record counter shows 1 of 1749. The moment I hit the next record arrow the custom record counter displays "2 of 1749" and if I go back again it displays "1 of 1749.".
I know it's a filter causing the problem because I have a macro that does a clear search. As soon as I hit the clear search the custom counter goes back to "1 of 501" again (even though the built in one stays at 1 of 1749).
Having set a table short text field to 'Indexed (No Duplicates)', I have a form which produces a '2105 runtime error' when the user attempts to submit a duplicate value. I would like to replace this default error message with a more user-friendly MsgBox.
My code for the SaveRecord button is:
Code:
Private Sub SaveRecord_Click() DoCmd.GoToRecord , , acNewRec MsgBox "Record successfully saved", vbOKOnly + vbInformation, "Record Saved" End Sub
My code to capture the 2105 runtime error is:
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer) If DataErr = 2105 Then MsgBox ("This villa booking has already been logged.") Response = 0 End If End Sub
Unfortunately when the save button is clicked (when attempting to save a duplicate value), the 2105 error still runs. What are I doing wrong?
It is my understanding that a custom macro was built to pull text data from a file and import it into Access in the appropriate fields. This macro no longer works and will return the following error message:
"License information for this component not found. You do not have an appropriate license to use this functionality in design mode."
It only gives an option to click OK. When you do it shows a box called "Action Failed" that lists the macro name, condition, action name, and arguments with three button to click on the right of the box: "Step" "Halt" and "Continue". It appears that only the "Halt" button is available to be clicked.
Does this sound like an issue with the Access license or whatever license the macro might have? We're trying to decide if it's possible to restore the functionality of the macro.
I am new to access. I have an application which has a custom tool bar. I tried to find the corresponding code for the custom tool bar by using the name of the tool bar. But was unsuccessful.
I want ot find the corresponding code for it. Where can I find the custom tool bar code in the VBA code of the applcaition?Actually, I want to add macros, queries and forms as a dirsct short cut in the existing custom tool bar.How to add macros and queries to the existing tool bar??
I have been tasked to create a multi-keyword search form, however, my form isn't working right and only the first record of the table is opened.
Code: Public Sub txtSearch_AfterUpdate() Dim strWhere As String Dim strWord As String Dim varKeywords As Variant Dim i As Integer Dim IngLen As Long
[Code] .....
These are the codes that I am using for my search form. I have a feeling that I am not calling the variable from the after update portion the right way.
I have 28 combo boxes on a form, which I want to insert data into the table as they are changed. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Sub routine:
Code: Private Sub cboMonday1_AfterUpdate() If Me.cboMonday1 = 1 Then Me.cboMonday1.BackColor = vbGreen Me.cboMonday1.ForeColor = vbBlack
All i want to do is after executing the following code, close the form " EmployeeFind" on completion?
Private Sub Form_DblClick(Cancel As Integer) On Error GoTo Err_Form_DblClick Dim stDocName As String Dim Msg, Style, Title, Response Msg = "Employee allocated to Job" Style = vbOKCancel + vbInformation Title = "Employee moved" ' Define title. Response = MsgBox(Msg, Style, Title) If Response = vbOK Then
I have never tried passing variables while calling a function so I don't know what the heck I'm doing. I'll give a simplified example of what I'm trying to do. The second variable vRank is reporting properly but the first one vID gets "stuck" on whatever the first item in the listbox is.
Code: Dim vrt As Variant Dim upSQL As String For vrt = 0 To Me.List1.ListCount - 1 If Me.List1.Selected(vrt) = True Then Call ChangeUp(Me.List1.Column(0, vrt), Me.List1.Column(1, vrt))
I have code for calling stored procedure with parameters,which is as follows
Dim qdf As DAO.QueryDef, rst As DAO.Recordset Dim IdValueToProcess As Long
IdValueToProcess = 221177 ' test data Debug.Print (IdValueToProcess) Set qdf = CurrentDb.CreateQueryDef("")
[Code] ....
And my stored procedure is
Code: ALTER PROCEDURE [dbo].[spItemDesc] @ItemNo varchar(200) , AS BEGIN set nocount on ; select ProductDesc1,ProductDesc2 from ProductDatabase.dbo.tblProductInfo where ProductNumber = @ItemNo END
is there a way to tell access to do REALLY nothing, like a sleep command?
on a form, I wanted to make a slideshow button which would skip to the next record after some seconds. but in those seconds i need to display 2 graphs and there is the problem i'm facing.
using something like a loop makes access really busy (as a process) and graphs use a different process (graph.exe) and that process doesn't get any processingtime...
I am trying to write the code which will show a Message Box if another field in a table is "Not Null" . Here is what I am attempting:
Upon exit of [JobFieldname] Look at record in [Table].[Jobinfo]. where [JobFieldname] match If [Yes/Nofieldname] = "Yes" then Open Message Box "My message Here"
Can someone help me? I havn't found the answer looking through the threads.