MsgBox Closing Main Form Then The Correct Form?

Aug 25, 2005

Hi all,

I've added a message box to what is basically a standard simple to use access control, "closeForm", I'm a newbie working on learning access vb. I'm guessing my code if fudged. Any help is greatly appreciated.

Private Sub Close_Click()
On Error GoTo Err_Close_Click
Dim Answer As Integer
Answer = MsgBox("Press Ok to Close, Cancel to Continue.", vbOKCancel + vbQuestion, "Exit Data Entry?")
If vbOK Then DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub


Thanks to all in advance

View Replies


ADVERTISEMENT

Subform Correct Answer Adds To Number Correct In Main Form

Mar 2, 2012

The code I have is.

Code:
Private Sub Command26_Click()
If Forms![test site]![prp test].Form.[A Right Answer] = -1 Then
Forms![test site]![number correct] = Forms![test site]![number correct] + 1
End If
DoCmd.FindNext
End Sub

Then when clicked it checks a yes/no box to see if "A right Answer" is the correct yes. Then it should pop to the main form and take the number correct cell and add one to it. I am trying to get the record to go to the next record inside the sub-form but docmd.findnext seems to be wrong too.

View 4 Replies View Related

Subform Not Displaying Correct Records From Main Form

Feb 23, 2005

Hello. The problem I am having is related to two tables. I have a table called Void and a table called Panel. A panel can have multiple voids and a void is assigned to only panel (one-to-many). In the Panel table, I set an autoincrementing number(SprayPanelId) for the pK. In the Void table, I set an autoincrementing number (VoidId) for the pk. I place the SprayPanelId into the Void table as a foreign key (same name in the void table). The problem I have is in my forms. I created a Panel form with a button to open a subform for data entry on the voids related to the panel in a new window. Data can be entered and is properly saved in the Void table. I open the Void table in a datasheet view under the table section and see it is properly there. I can run queries where Void.SprayPanelId = Panel.SprayPanelId and it returns the correct void with the correct Panel. The problem becomes when I open my void subform, it no longer displays that record associated with that panel. however, the record is there in my void table. Any thoughts? Do I need a filter perhaps, run any sql commands? Thanks in advance, Kevin

View 2 Replies View Related

Forms :: Closing Opening Form With Timer Then Opening Main Menu

Apr 7, 2014

I have a Form opening from Access Options. I would like to close this Form using the Timer. The following is the code I have used but it is not working.

Private Sub Cover_Page_Form_Load()
OpenTimer = Timer
End Sub
Private Sub Cover_Page_Form_Timer()
If (Timer - OpenTime) = 5 Then DoCmd.Close acForm, "Cover_Page_Form", acSaveYes
End Sub

Next question. If I can get this to work can I then use a DoCmd to open new Form within the code above or do I need a new process.

View 5 Replies View Related

Database With A Main Menu Form Containing A Button That Loads Main Data Entry Form

Jun 24, 2015

I have a database with a Main Menu Form, containing a Button that loads my main data entry form. When the Button is Clicked portions of the data entry form that is loading shows through the Main Form Background (e.g. portions of the navigation bars, and portions of the boarder on the form that is loading.)

View 5 Replies View Related

Why Is Main Form Update Event Triggered When Subform Dirties Main Form?

Dec 1, 2005

I have a subform which makes a change to a field on the main form. When focus is returned to the main form, the BeforeUpdate and AfterUpdate events fire. Why? I thought from the form's perspective, the subform is just another control.

BTW, I get the same behavior if I modify the field from within the Exit event of the subform control.

In either case, the main form's Dirty event is NOT triggered.

View 2 Replies View Related

Forms :: Access 2010 - Opening New Form And Closing Current Form?

Mar 14, 2013

I am using Access 2010 - Version 14.0.61.29.5000 (32-bit)

I am building a custom Export Wizard to export data to Excel using the Report Wizard for the basic ideas.

All I am trying to do is have a [Back] button on a form to open another form and close the current form.

Private Sub cmdBack_Click()
DoCmd.OpenForm "frm_ExportWizardPage2", , , , , , Nz(Me.OpenArgs)
DoCmd.Close acForm, "frm_ExportWizardPage3"
End Sub

The new form is opening but then the current form is not closing. All forms are the same size, shape and positioned centrally although this should not make any difference.

Could this be anything to do with which form has the focus when I open the new form?

View 2 Replies View Related

Forms :: How To Use Data On A Form When Running Code Before Closing The Form

Feb 4, 2014

I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.

When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).

Is there a way to trap Data on form just before the form closes?

View 4 Replies View Related

Modules & VBA :: Error Msg On Form With Form Closing?

Nov 13, 2014

I got an error msg on form with closing. I have a main form (SalesReturnOrDamaged) and subform (SalesReturnOrDamagedSubform).

i have used a VBA code on main form Close Command button as per shown in Code Tag. But that is not working and shown an error msg as per screenshot. how to change that VBA code for empty form close without save the record?

Code:
Private Sub Close_Click()
On Error GoTo Err_Close_Click
If Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![ItemCode].Value = "" Then
Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![Product].Value = ""
Forms![SalesReturnOrDamaged]![SalesReturnOrDamagedSubform].Form![MRP].Value = 0 Or ""

[code]......

View 1 Replies View Related

Forms :: Send Data From Pop-up Form To Main Form (sub-sub Form)

Aug 27, 2014

On the form: User enters first name, then last name. Upon updating the last name field, I would like another form to pop-up and display all the people with that same first name and last name that the user just entered.

On the pop-up form: All of the matching first names/last names are listed with a button control beside each record that says 'Select'. The user clicks the select button beside the record he/she wants. This pop-up form closes and all of the data from this selected record is now showing on the original form.

So far, I have a query/form that pops up only showing the matching first/last names. I'm having a hard time getting my original form to auto-populate with that record that the user selects on the pop-up.

(Also my main form is actually a sub-sub form - so in my trials I could've been massacring my syntax trying to point to it.)

View 5 Replies View Related

Main Screen Subform Based On Query Reflecting Changes Only On Closing Database

Jun 25, 2006

I have a problem in reflecting the updated changes on a main screen subform based on a query .These changes get reflected only after closing the access database and reopening it .Tried the requery command. Also made a macro to update the query and run it after the form opens or load but not reflecting change in main screen immediately .I would be grateful if I can get some help on this forumThanks

View 3 Replies View Related

Open Form While Closing Form

Oct 26, 2006

this has to be simple but i can't get it to work...

i have a selection form (frmSelection) with a combo box...the user makes a selection from the combo box and based on that selection another form opens when they click next...i have a Select Case under cmdNext_Click()..here's a sample of what that looks like:
Select Case cboVioCat.Value

Case 1 ' loads frm_vw_lab_all_facility
frm_Name = "frm_vw_lab_all_facility"
DoCmd.OpenForm frm_Name, acNormal
Case 2 ' loads frm_vw_lab_all_other
frm_Name = "frm_vw_lab_all_other"
DoCmd.OpenForm frm_Name, acNormal
Case Else
strMsg = "Please make a selection from the list"
MsgBox strMsg, vbInformation, "Oops!"

End Select
now what i'd like to happen is say the user selects the first option "Case 1", the new form opens...this works perfectly...but what i'd also like to happen is frmSelection to close - it is no longer needed...i have added DoCmd.Close within each Case and after the End Select but none work...it appears as though it is closing the new form, frm_vw_lab_all_facility...what am i missing here?

View 3 Replies View Related

MsgBox Appear After Form Loads?

Mar 16, 2005

hello all,
i have a form which I have set so that it opens a blank record once opened. After it has been opened I want a msgbox to appear. my code so far is:
---------------------------------------
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec

Select Case MsgBox("Please select the Registration Number from the drop down menu or type it in", vbOKOnly, "Select Registration Number")

End Select
End Sub
-------------------------------------------

but the problem is that the msgbox appears before the form is opened.
any ideas how to fix this would be grately appreciated. thank you

View 4 Replies View Related

MsgBox To Show In The Middle Of The Form

Dec 30, 2006

Hi,

I have a Form that is modal and popup, and which opens without the MS Access in the background. It is like a separate window (piece of program) that runs under Windows XP.

If I move the Form on my screens (I have dual monitors) I would like that the messages that are triggered by various actions to appear on top of the form not - for example - on the other screen .

I can add more info if necessary.

Thanks for help.

View 2 Replies View Related

Code To Open Form Using Msgbox

Mar 28, 2007

Hello,

My database has two main tables: Table1 and History

Users can add data to this table and decide if store part of data into the History table using an append query behind a cmdbutton. I do this to create an Historical Log of my records.

I then have a main form (form1) with the following code on the OnCurrent event:


If Not IsNull(DLookup("[SSN]", "history", "[SSN] = '" & [SSN] & "'")) Then
msgbox "Record present in the Historical Log!", vbOKOnly, "Warning"
end if


I would now like to change this code so that users are prompt with a message that allows them to either open the form1 or the Historical log (frmHistory)

I would need something like this but cannot get it to work:

If Not IsNull(DLookup("[SSN]", "history", "[SSN] = '" & [SSN] & "'")) Then
msgbox "Record present in the Historical Log!", vbYesNo, "Warning"
If vbYes Then
DoCmd.OpenForm "frmHistory", acNormal, "qryhistoryfrommsgbox", "", , acNormal

If vbNo Then '
'open the regular form1.


Another thing I cannot figure is why this pop up msg comes up even if I close the form. Is there a way to revome it from the close form event?

Thanks.

View 4 Replies View Related

Forms :: Msgbox - Yes Or No Based On Value On Form

Aug 13, 2013

I have a form with one field on it. I want to be able to look up a value on this form and based on whether it is in the table or not give a message box saying yes it is there, or no it is not and then reset the form to look up another value.

View 3 Replies View Related

If No Matches Reopen Form After Msgbox

Jul 18, 2012

I currently have an unbound form I am using as a switchboard. When a button is pressed it loads a form asking for the user to enter their password (the swtichboard is then closed). If the correct password is entered the form opens to their details, when that form is closed, the swtichboard re-opens. I want an action that if the correct password is not used, then a msgbox lets them know and then the Switchboard they were at re-opens. So far I have the following code:

Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
MsgBox "Incorrect Password!"
Cancel = True
End If
End Sub

This works well, but I am unsure how to write that after the msgbox I want the Switchboard to open. I tried to add "DoCmd.OpenForm frmSwitchMain" in various places, but I am unsure on the proper procedure to do this.

View 2 Replies View Related

Forms :: Open Blank Form Based On Value In Text Field In Main Form

Jun 6, 2013

I have one table containing name of restaurant with its address etc. Then i created another table to list out the restaurant workers names and details. Just as an example,

Table:Restaurant
Restaurant name
Address line 1
Address line 2
Restaurant #
Website

Table:StaffContact
Staff Role
Name
speciality
email
phone

I have the main form that has all the restaurant details only. And i have another form containing the Staff information. Please note the two table have a relation and it works well.

Now to make it user friendly(basically easier for the lazy ones), I dragged the staff contact form on to my main form and displayed it as a datasheet(basically a sub form).

Now, my boss does not want users to add/delete on this sub form(datasheet). So,he wants me to create buttons to open new record of staff for each restaurant(new form)

My issue is with opening a new record to enter a new person to the staff list and give them a role as well in form view.The new form has

So i ran a Macro, with open form with Where condition

Code:
[Staffcontact]![Rest Name]=[Forms]![MainForm]![RestaurantName]

But, it does not work .

View 2 Replies View Related

General :: Clear Sub Form At The Time Of Opening The Main Form?

Jul 24, 2013

I have a form, which is comprised of a sub form, and some of the text box controls sided with a button, and the event had been written to the button.

Now, to give a note on how had the sub form had been created is firstly taking a clone of the "Payments" table and using it as a datasheet, and then create a sub form in the form, it works fine

View 2 Replies View Related

Forms :: Main Form Which Contains A Sub Form In Data Sheet View

Nov 28, 2013

I have a main form (tsTimeSheetMain) which contains a sub form (tsTimeSheetDataNewSub) in data sheet view. When I click off one row onto another row in the sub form, it triggers this code:

Forms!tsTimeSheetMain!ProjectMonSum.Requery

i.e. it tries to requery the ProjectMonSum field (on the main form) which is a dsum calculated field. This works fine and updates the ProjectMonSum field (which dsums values from the same datasource as the subform.

However, this seems to put the cursor back to the top left field in the subform (datasheet view), rather than leave it in the field I click on (in the subform).

Why is this happening and what is a decent workaround this issue? I just want to update the calculated dsum field each time you update values in the subform.

View 8 Replies View Related

Display Form Correct With Different Resolutions

May 9, 2006

One of my probs with access is changing the form when a different resolution is being set.
Is there a visual basic module or something else to display the form properly dependent of the selected resolution?

View 1 Replies View Related

Closing A Form Vs. Really Closing A Form

Feb 17, 2005

This is related to some advice I received some time ago <a href="http://www.access-programmers.co.uk/forums/showthread.php?t=64818">here<a>

I am runnign some code, it performs some applications, then, if a Count Field is greater than 1, a form opens as a dialog, displaying some information:

Dim A As String
A = "NewForm"
If Me.[Count] > 0 Then
DoCmd.OpenForm A, acNormal, , , , acDialog
End If
If Me.Continue = "No" Then
Exit Sub

End If

The new form opens, and you can either view it, and click continue, which will run the rest of the code, or you can click quit, which updates Me.Continue to "No", and then it exits.

The problem is, when it exits the Sub, it doesn't really stop the code, it just leaves things kind of hanging. When I try to run the code again, I get:

3321 - The database engine could not lock the table 'NewTable' becuase it is already in use by another person or process.

Another symptom - The original form where I click to start running the code, has two date fields. Normally, when this form opens, they are blank, but when I exit the sub, as above, the previous dates I entered are still sitting there.

How can I make the forms really close?

View 2 Replies View Related

Closing A Form

Jul 14, 2005

When a form is open you can also see on the task bar that the form is open
If the user right clicks on the form(on the task bar ) they get the following options minimize , maximise , close.

Does any one know how I can stop the user selecting Close please ?

View 6 Replies View Related

Closing Of Form

Oct 11, 2006

when i close the form all the fileds in the forms gets saved to the table.
i want it should pop up before closing to save it or not.
i have a button on the form to save the fields in the table.
which has code

command23_Click()
DoCmd.GoToRecord , , acNewRec

View 6 Replies View Related

Hide Fields In Main Form By Clicking Sub Form

Apr 11, 2005

I have one main form with 3 tabulated sub forms.
My main form consists of two fields.
When the user clicks tab 2 (subform 2) or tab 3 (subform 3) the main fields should hide

I tried to achieve this by using the on click event at the tabbed forms. I referenced the two main fields and used the visible property followed by a form requery. It didn't work.

thanks in advance

View 1 Replies View Related

Use Popup Form To Select A Record On Main Form

Sep 2, 2006

I'm not sure how to search on this, even in the advanced search. If this has been answered, could you point me in the right direction?

I have a main form AddNewCompany (the infamous tab control that now works - thanks to your combined efforts). On it I have a command button that pops up a form of continuous forms with all the companies in the table (the query calls the CompanyID and CompanyName fields only). I have attached an image of the interface.

This means the user can see if the company already exists and doesn't enter it again. (I'm sure there are more effecient ways of doing this, but this is simple and it works. I also know key fields should be autonumbers instead of text, but I have reasons for doing it this way).

What I would like to be able to do is click on the CompanyID field and have the companies information show up in the main form.

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved