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 Replies


ADVERTISEMENT

MsgBox To Appear Based On Code

Nov 9, 2006

Dear all:

I have a database with the following info: Last_Name, First_Name, ID number and major_code. The major_cd is a 3-digit alphanumeric code.

I have created a search field using the wizard to find a person by ID number which works fine. When a person is found the Last_Name, First_Name and major_code fields populate.

Is it possible to have a pop-up box appear based on a specific major_cd that is already in the database?

I am most apprecative to anyone who can help.

MANY THANKS!

Dion

View 5 Replies View Related

General :: Way To Get A Msgbox To Show Only When Db Is Open For First Time

Nov 14, 2012

Is there a way to get a msgbox to show only when the db is open for the first time. So basically what I want is when I push an update it will auto check to see if the db is current if not then it closes an opens the new db. When it opens the new db i want it to display a msg box or form that shows the new updates. Then if they exit an reopen it wont show the option.

View 10 Replies View Related

Modules & VBA :: How To Open Report From Msgbox With A Condition

Jan 13, 2014

i have a form to enter a new client if the client is existed then a message box appear and tell me that this client is existed and his number id is ## with two buttons yes and no.if i click yes i should go to a report that contains information about that user and this report take his data from a query

new client save code
---------------------
Dim MSG As Integer
Dim ExistentID As Long
ExistentID = Nz(DLookup("P_ID", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N"), 0)
If ExistentID > 0 Then

[code]....

when i click yes the report should open with the existent id but he open a input box to ente an id and his title is tbl_personal_information.PID it's the ID field that it's named P_ID in the query

View 4 Replies View Related

Close Current Form And Open A New One Code

Aug 29, 2005

Hi

I need a button code in the OnClick event.

I want when clicking on the button, to close the currently opened form and open another one.

Any help will be very much appreciated!

Thanks guys!
C.

View 10 Replies View Related

Form Open Code To Select A Parameter

Oct 9, 2006

I have a database with lists clients across the UK. I have now been asked to provide options where users can select clients grouped by geopraphical area e.g say clients in Scotland.

I can of course do this but having numerous identical forms where the source queries have different parameters depending on the regions required.

The only problem with this is that I would need numerous forms and queries. Additionally, there are options on the form to navigate to linked forms which would all need to be unique.

What I would like to have options on my main (Switchboard Type) Introduction Form to select the region. The code on the relevent command button would include the parameter. I would therefore not require the additional forms.

The open form codes includes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmClients"
DoCmd.OpenForm stDocName, , , stLinkCriteria

I feel i need something after "frmClients" such as qryClients.ClientArea = "Not Scotland". Various attempts to incorporate something has created errors.

Any quidance on code would be appreciated.

Thank you...Paul

View 3 Replies View Related

Need Help With Double Click Open Form Code

Dec 14, 2006

Hello..

I have the following code that I have been trying to get to work:

Private Sub txtSocNumber_DblClick(Cancel As Integer)
On Error GoTo Err_txtSocNumber_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmApplicantFullDetails"

If IsNull(Me.txtSocNumber) Or Me.txtSocNumber = "" Then
MsgBox "This record is empty", vbInformation, "No Data"
Me.txtSocNumber.SetFocus
Else
stLinkCriteria = "[ApplicantID]=" & Me![InvestigatorID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_txtSocNumber_DblClick:
Exit Sub

Err_txtSocNumber_DblClick:
MsgBox Err.Description
Resume Exit_txtSocNumber_DblClick
End Sub


I have the following two tables:

Applicant and Investigator

Applicant:
ApplicantID
InvestigatorID
etc

Investigator:
InvestigatorID
etc

The relationship is setup as 1 investigator to many applicants.

What I am trying do is this. I have form with a subform in it. In the subform there is applicant info IE SS# LName, FName and that is it. What I want to do is be able to double click on the SS# have the form "FrmApplicantFullDetails" open so you can view the work up on the applicant or edit info on the applicant.

Am I going about this the right way with the above code? Or is there something else I am missing in the code or is there code out that will do what I am looking for that is easier?

Thanks
R~

View 5 Replies View Related

Forms :: Show VBA Code On Form That Will Not Open

Dec 19, 2014

In the initial Form_Open code there is a string that fails before the form is open, preventing me from opening the form and accessing the VBA code to correct the problem.How can I access the VBA code to correct the problem if it otherwise prevents me from opening the form so I can access the VBA code?

View 7 Replies View Related

Need Code To Open TeacherDetailFrm Form Main Form.

Jun 11, 2007

Hi
I need code to open TeacherDetailFrm form Main form.

I have TeacherStudentSubFr*m on the Mainform, FirstNameTxt on the TeacherStudentSubFr*m, and TeacherDetailFrm.
I need code to open the TeacherDetailFrm By double click on the FirstNameTxt.

I use this code but no data come and query dialog box come.

Private Sub FirstNameTxt_DblCli*ck(Cancel As Integer)
Dim DocSubForm As String
Dim DocText As String
DocSubForm = "TeacherDetailFrm"
'DocText = "[Result]=" & "'" & Me![result] & "'"
DoCmd.OpenForm DocSubForm, , , "[ FirstNameFld ]=forms![TeacherStudentSubFrm]![ FirstNameTxt]"

End Sub


I like to upload the file but no way in this forum

View 2 Replies View Related

Modules & VBA :: Code To Open A Form To A Specific Record

Sep 4, 2014

I am using a datasheet view with dbl click code to open a form to a selected record. I was able to use pbaldy's code and it worked perfectly.

DoCmd.OpenForm "Asset Status", , , "[Project Number] = '" & Me.Project_Number & " ' "

Then I realized I really want to be able to go to other records after I have gone to this form and tried this:

Dim rs As Object
Dim lngBookmark As Long
'set variable to the current record
lngBookmark = Me.Project_Number
'open new form

[code]....

But to no avail. Project_Number is a text field.

View 12 Replies View Related

Correct Code Command To Keep Form Open After Selecting Close Control Box Button?

Oct 13, 2015

I am at my Login Screen, I want it to return to the Login Screen if you select "NO" and Close the DB if "YES"

Here is my current code:

Private Sub Form_Close()
If MsgBox("Would you like to EXIT the Database?", vbYesNo, "Quiting Database") = vbYes Then
Application.Quit
Else
???
End If
End Sub

View 5 Replies View Related

Can't Open PDF - Code Included

Sep 26, 2005

With this code, I can open Word and Excel files, but not PDF. Please let me know what I'm doing wrong. (I tried changing strProg = "C:Acrobat.lnk" including to a .exe file but nothing happens when I click the Open button)

---------------------------------------------------

Private Sub cmdOpen_Click()

Dim sSourcePath As String
Dim strProg As String
Dim objword As Object
Dim strFile As String
Dim XL As Object

sSourcePath = Me.FilePath

DoCmd.RunCommand acCmdSaveRecord

If fIsFileDIR(sSourcePath) = -1 Then

Select Case ParseFileName(sSourcePath, 3)

Case "xls"

Set XL = CreateObject("Excel.Application")

If IsNull(Me.FilePath) Then
MsgBox "You haven't Attached a File"

Else

With XL.Application
.Visible = True
.workbooks.Open Me.FilePath

End With

Set XL = Nothing

End If

Case "doc"

Set objword = CreateObject("Word.Application")

strFile = Me.FilePath

objword.Visible = True
objword.Documents.Open strFile

'--------------------------------------------------
Case "pdf"
'Open File

strProg = "C:Acrobat.lnk"

Call Shell(strProg & " " & sSourcePath, vbMaximizedFocus)


Case Else

MsgBox "File type not recognised"

End Select

Else

MsgBox "File cannot be found. Please check the file path. ", vbExclamation

End If

End Sub

View 1 Replies View Related

Open Database From Code

Dec 16, 2004

is there a possibility to open a compleet other database from you database out?

no matter what the location is (i give the location)

thx in advance

View 4 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 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 5 Replies View Related

Executing Code On Database Open?

Apr 10, 2007

hi,

I was wandering if it is possible to implicitly execute code upon the opening of a database? If so how do I do this? I have code to convert the page settings of a report from a command click but wanted this to be done automatically...

cheers

tania

View 6 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

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

Code To Open A Wordpad File From A Button?

Aug 24, 2007

Does anyone know the code for opening a specific notepad file from a button? I know there's a default button but it only opens a blank notepad page. I need to open some written instructions from a button you see.

Thanks.

View 3 Replies View Related

Open File Code In Visual Basic

Jan 5, 2007

Hello!

I am an access novice so was wondering in anyone can help me.

Can anyone post the code I need to enter to do the following;

1) Import a file from my local hard drive into a designated table in access

2) Export a number of tables back onto my local hard drive

I would like it so these actions occur when I click on the relevent command box on my form

Any help would be very much appreciated

View 1 Replies View Related

General :: Open File In Dialog Box Code

Aug 8, 2013

this cod ein access vba for opening a file dialog and selecting a file in a textbox ..

Private Sub Command26_Click()
Dim fDialog As Object
Set fDialog = Application.FileDialog(msoFileDialogOpen)

[Code]....

this code,on the form i have a button whose click event is this code and a a text box with it which is text29.

It gives an erro

Run time error '2185':

you cant refernce a propery or method for a control unless the control has the focus .

View 1 Replies View Related

Modules & VBA :: Code To Search For TIF File And Then Open It

Aug 15, 2013

How to write some code that will search a known drive and folder structure for a tif file and on finding it, open that tif file.

The known drive/folder structure is as follows:

M:CustomerSatisfactionStdDGImages

or it could have the full path as follows:

prdfs01QUESTIONSCustomerSatisfactionStdDGImag es

and then there are the following folders which contain any number of tif images:

01_Q
02_Q
03_Q
04_Q
05_Q
06_Q
07_Q
10_Q
11_Q
12_Q
13_Q
14_Q
17_Q
18_Q
19_Q
20_Q
21_Q
23_Q
24_Q
28_Q
29_Q
30_Q
31_Q
32_Q
33_Q
34_Q
35_Q
36_Q
37_Q
38_Q
39_Q
AR_Q
HE_Q
SKY_SKY3B

I would like to have a button in a form that the end user clicks and they then enter the name of the tif file they are looking for and on pressing enter the file is searched for and if found it is automatically opened up for them to see, if it is not found then a message "File Not Found" is displayed.

I Believe that I will need something like this:

Code:

Dim FS As FileSystemObject
Dim filenum As Integer
Dim tmp As String
Dim Folder As Folder
Dim subFolder As Folder
Dim File As File

[Code] .....

It's when I get to this point that I've got stuck, I don't know how to structure the code required to do the search and on finding the tif file open it.

An example tif file I might search for is: 0H214_2CJ0001905.tif.

View 11 Replies View Related

Adding A Msgbox To A Search Form - Easy Peasy Except For Me :)

Sep 11, 2005

I have a code for a free text search form which will return records in another window when the search button is clicked.


CODE
Private Sub cmdSearch_Click()

If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."

ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"

'Filter frmRhinitis based on search criteria
Form_frmRhinitis.RecordSource = "select * from tblBaseline where " & GCriteria
Form_frmRhinitis.Caption = "Customers (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"

MsgBox "Results have been filtered."


End If

End Sub





However, even if no records match the criteria the window will return a "Results have been filtered" but return a blank form. How do I include code that will return a "Match cannot be found" MsgBox if the search string isnt found?


Thanks :)

View 3 Replies View Related

Modules & VBA :: Bring Up Msgbox If Certain Fields Blank And Not Run The Macro In Form

Jan 20, 2015

I have a form with various text, date and combo controls. There is a button at the button that runs a macro (Close NB) at the bottom. What I'm trying to do is bring up a msgbox if certain fields are blank and not run the macro. I only want the macro to run if all the fields specified have data in them.

The fields are :
cmb_cliname
cmb_disease
cmb_projectType
cmb_ProposalStatus

The on click code is:
If (Me.cmb_cliname Is Null) Then
MsgBox "Please fill in the relevant details",
ElseIf (Me.cmb_Disease Is Null) Then
MsgBox "Please fill in the relevant details"

[Code] .....

View 6 Replies View Related

Form Filter Combo - Msgbox When User Tries To Enter Data

Jun 1, 2012

I use filter Combo boxes in a lot of places so that users can filter records easily. (Not combo boxes for input).I have them labeled as filters but nonetheless users keep trying to input into them for some reason.How would I add a message box to it so that it states that 'this box is not for data entry etc'.

View 2 Replies View Related







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