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 Replies


ADVERTISEMENT

Having Trouble In Executing TreeCtrl Code

Jul 11, 2006

Hi,

I am having trouble in implementing the TreeCtrl structure. I have a simple database for testing purpose and I am not able to make it work. There appears to be a problem with the bookmark property and I get an error message:
"can't Add child:Arguments are of wrong Type, are out of acceptable range, or are in conflict with one another".

I have attached the database here and could you please see what is wrong with my code.


Thanks
Priya

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

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

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

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

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

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

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

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

Executing Query

Oct 15, 2007

Hi there,

I am trying to run a query from an ASP page, which also uses other queries. I get the following error message: [Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'Expr1' as part of an aggregate function, this is in qrySessionsEverything.


The query name is qrySessionsEverything.
It executes the line:

SELECT * FROM qrySessionsEverything

The queries are below:

qrySessionsEverything
SELECT tblSessions.SessionID AS Expr1, tblSessions.CourseID AS Expr2, tblCourses.CourseName AS Expr3, tblSessions.SessionDate AS Expr4, tblSessions.StartTime AS Expr5, tblSessions.EndTime AS Expr6, tblVenues.VenueID AS Expr7, tblVenues.VenueName AS Expr8, tblVenues.Capacity AS Expr9, tblVenues.Capacity-[bytAttendees] AS bytAvailablePlaces, qrySessionsAccepted.bytAttendees AS Expr10, tblVenues.Link AS Expr11, qrySessionsPending.Pending AS Expr12, [TrainerFirstName] & " " & [TrainerSurname] AS strTrainer, tblSessions.TrainerID AS Expr13
FROM tblTrainers, tblCourses, qrySessionsAccepted, qrySessionsPending, tblVenues, tblSessions
GROUP BY tblSessions.SessionID, tblSessions.CourseID, tblCourses.CourseName, tblSessions.SessionDate, tblSessions.StartTime, tblSessions.EndTime, tblVenues.VenueID, tblVenues.VenueName, tblVenues.Capacity, qrySessionsAccepted.bytAttendees, tblVenues.Link, qrySessionsPending.Pending, [TrainerFirstName] & " " & [TrainerSurname], tblSessions.TrainerID;

qrySessionsAccepted
SELECT tblSessions.SessionID AS Expr1, tblSessions.CourseID AS Expr2, tblSessions.SessionDate AS Expr3, tblSessions.StartTime AS Expr4, tblSessions.EndTime AS Expr5, tblSessions.VenueID AS Expr6, tblVenues.VenueName AS Expr7, tblVenues.Capacity AS Expr8, [Capacity]-[bytAttendees] AS bytAvailablePlaces, Count(qryDelegatesAccepted.DelegateID) AS bytAttendees, tblVenues.Link AS Expr9
FROM tblVenues, tblSessions, qryDelegatesAccepted
GROUP BY tblSessions.SessionID, tblSessions.CourseID, tblSessions.SessionDate, tblSessions.StartTime, tblSessions.EndTime, tblSessions.VenueID, tblVenues.VenueName, tblVenues.Capacity, tblVenues.Link
ORDER BY tblSessions.SessionDate, tblSessions.StartTime;

qrySessionsPending
SELECT tblSessions.SessionID AS Expr1, tblSessions.CourseID AS Expr2, tblSessions.SessionDate AS Expr3, tblSessions.StartTime AS Expr4, tblSessions.EndTime AS Expr5, tblSessions.VenueID AS Expr6, tblVenues.VenueName AS Expr7, tblVenues.Capacity AS Expr8, tblVenues.Link AS Expr9, Count(qryDelegatesPending.SessionID) AS bytPending
FROM tblVenues, tblSessions, qryDelegatesPending
GROUP BY tblSessions.SessionID, tblSessions.CourseID, tblSessions.SessionDate, tblSessions.StartTime, tblSessions.EndTime, tblSessions.VenueID, tblVenues.VenueName, tblVenues.Capacity, tblVenues.Link
ORDER BY tblSessions.SessionDate, tblSessions.StartTime;

qryDelegatesAccepted
SELECT tblDelegates.DelID AS Expr1, tblDelegates.SessionID AS Expr2, tblDelegates.DelTitle AS Expr3, tblDelegates.DelFirstName AS Expr4, tblDelegates.DelSurname AS Expr5, tblDelegates.DelHospital AS Expr6, tblDelegates.DelDepartment AS Expr7, tblDelegates.DelPhone AS Expr8, tblDelegates.DelBleeper AS Expr9, tblDelegates.DelEmail AS Expr10, tblDelegates.DateSubmitted AS Expr11, tblDelegates.Accepted AS Expr12, tblDelegates.Rejected AS Expr13
FROM tblDelegates
GROUP BY tblDelegates.DelegateID, tblDelegates.SessionID, tblDelegates.DelTitle, tblDelegates.DelFirstName, tblDelegates.DelSurname, tblDelegates.DelHospitall, tblDelegates.DelDepartment, tblDelegates.DelPhone, tblDelegates.DelBleeper, tblDelegates.DelEmail, tblDelegates.DateSubmitted, tblDelegates.Accepted, tblDelegates.Rejected
HAVING (((tblDelegates.Accepted)=True) And ((tblDelegates.Rejected)<>True));

qryDelegatesPending
SELECT tblDelegates.DelegateID AS Expr1, tblDelegates.SessionID AS Expr2, tblDelegates.DelTitle AS Expr3, tblDelegates.DelFirstName AS Expr4, tblDelegates.DelSurname AS Expr5, tblDelegates.DelHospitall AS Expr6, tblDelegates.DelDepartment AS Expr7, tblDelegates.DelPhone AS Expr8, tblDelegates.DelBleeper AS Expr9, tblDelegates.DelEmail AS Expr10, tblDelegates.DateSubmitted AS Expr11, tblDelegates.Accepted AS Expr12, tblDelegates.Rejected AS Expr13
FROM tblDelegates
GROUP BY tblDelegates.DelegateID, tblDelegates.SessionID, tblDelegates.DelTitle, tblDelegates.DelFirstName, tblDelegates.DelSurname, tblDelegates.DelHospital, tblDelegates.DelDepartment, tblDelegates.DelPhone, tblDelegates.strDelegateBleep, tblDelegates.DelEmail, tblDelegates.DateSubmitted, tblDelegates.Accepted, tblDelegates.Rejected
HAVING (((tblDelegates.Accepted)<>True) And ((tblDelegates.Rejected)<>True));


Please can you help me.

Thanks,
Bash.

View 1 Replies View Related

Executing Query In VBA

Oct 31, 2007

Hi, I am a beginner in access. I am trying to execute the below query through VBA on a click event on a Command Button in a Form. I am taking input parameter from Form, based on which I want the query result( dynamic Query Parameter).
I getting the attached error message

Please help me out in executing this query in VBA. An example would be of great help. Thanks in advance..

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

SQL INSERT -- Asking For Parameters When Executing?!

Jul 22, 2005

Hi all,

I've searched for a solution, and the proposed solution didn't work for me.

I am executing an SQL statement to insert values into a History table when deleting a value in a subform. Two of the 5 values are asking me for parameters when the SQL executes and I cant figure out why! The datatypes they are inserting into are correct and I'm at a loss. The 2 values giving me grief are Manufacturer and Model.

Here's the code:

Dim sSQLMachHistory As String

MsgBox "me.acctid: " & Me.AccountID
MsgBox "me.manufac: " & Me.Manufacturer & " me.serial: " & Me.SerialNumber
MsgBox "model: " & Me.Model

'Insert into History Table:
sSQLMachHistory = "INSERT INTO tblMachineHistory (SerialNumber, Manufacturer, Model, AccountID, MachineID) VALUES (" & Me.SerialNumber & ", " & Me.Manufacturer & ", " & Me.Model & ", " & Me.AccountID & ", " & Me.MachineID & ")"

MsgBox sSQLMachHistory

DoCmd.SetWarnings False
DoCmd.RunSQL sSQLMachHistory
DoCmd.SetWarnings True

My message boxes show me all the values are displaying and should be inserting into the table -- any ideas??? :confused:

cheers

Mike

View 2 Replies View Related

BeforeUpdate Event Executing Too Many Times

Oct 16, 2005

I have a mainform with a search function so the user can select a record to view and update. The selected record is displayed in Subform1 on Page1 of a tab control. The record source of this form is Query1. Page2 of the tab control contains Subform2; record source is the result of Query1 joined to Query2.

The forms correctly displays, updates and adds records my problem occurs when I add VBA code to the BeforeUpdate event of a control on Subform1. The code appears to execute once for each page in the tab control.

Has anyone any suggestions on how I can correct my problem.

Thanks

Fearless

View 3 Replies View Related

Executing Command Buttons On Other Forms

Sep 20, 2004

Hi

I have a Visible form and an Invisible (visible=false) form open at the same time. Is it possible to use a button on the visible form to execute the code behind a button in the invisible form. The subroutine on the invisible form is Public. I tried DoCmd.RunCommand and a macro with RunCode but... nada...

(There is a valid reason for this approach but i will spare you the boring explanation. I can think of a work around where I can bypass this need, but this way is cleaner (there are cases where the invisible form is visible and used directly, the form has data which is sent to a report to create a label). I have done everything else with VBA code but for some reason can't get this to work, so now i am obsessed)

Thanks, this forum is really a gem!

View 2 Replies View Related

Executing An Update Command With “'” In The String

Nov 3, 2006

Hi,
I try to execute an update command i.e.:
UPDATE Results set Data = 'Heiner's key' where ValidationNumber = 1 and TestNumber = 2 and Line = 'E1'.
Access does not let me do this because the “'” in Heiner's terminates the update string prematurely.
Does anyone have a suggestion how to do this? Thank you.

View 4 Replies View Related

Create Custom Box Before Executing Query

Jan 9, 2012

I am looking to check, whether i would be able to "add an Message box with a "Message : "Executes all queries all is well.mdb before executing this query ?" , if yes, continue executing the query, else, Exit out of the database?

View 1 Replies View Related

Modules & VBA :: Open Database / Run A Query / Close Database

Aug 22, 2014

i have a database that runs updates from within itself.what i need is, this database to then open a another database run a update query, then close it.

View 4 Replies View Related

Executing A Query On Periodic Basis At Midnight At 00:05

Oct 31, 2005

I am trying to execute query every midnight at 00:05 and append data into a table. This query reads the data from a linked table and appends the records into the local table.

Access doesn't triggers so I have no clue which way to proceed.

Can anybody help me creating a logic to execute query at midnight?

Regards
Giri

View 2 Replies View Related

Executing A Query On Highlighted Record In Listbox

Jul 25, 2005

How do i apply a query that i want to execute only on a highlighted record in a listbox.

If there is a link, sample database or lines of code could you please assist.

Currently everything is being executed on all of the records in the query.


Also Does Access 2000 support codes for drag and drop forms?

View 2 Replies View Related

Executing A Subforms Procedures From The Parent Form

Dec 19, 2005

is there a way i can call a sub forms procedure from the main parent form.

in other words i have a button command i want to execute

View 2 Replies View Related

Modules & VBA :: Error When Executing OnOpen Report?

Sep 8, 2013

I am using ACCESS 2010, win 7 Home Premium 64bit

difficult to handle error when executing my report. I put a code into OnOpen section but ACCESS states:

Quote:

The expression OnOpen you entered as the event property produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.

Additionally it says in description:

This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.

I am genuinely confused by that. I have also provided the code in the case if I am missing something I don't know yet. In a debug window, I have executed the code line by line and it worked. Whenever I try to open the report, the error occurs. Should I be aware of something when I write code for reports?

Below, the code in my report "module":

Code:
Private Sub Report_Open(Cancel As Integer)
Call CreateTempTable
End Sub
Private Sub CreateTempTable()
On Error GoTo ErrorHandler
Dim strTable As String

[code]....

View 3 Replies View Related







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