Access VB Modules

Jan 18, 2005

Hi guys, im working on a project whereby a Visual Basic module has been designed in MS Access to email out a RTF document attachment of reports to shift managers when they have hazard items not closed in their area. Im building an ASP front-end to the database and would like to incorporate a button to do the mailout, however i dont know how i can link it to fire the code when the button is pressed. Is it even possible?

Nath

View Replies


ADVERTISEMENT

Modules & VBA :: Emailing From Within Access?

Aug 29, 2014

I am trying to automate the process of sending a query result via email.

I have code that will export a query as an excel document, using DoCmd.SendObject, but it has the name of the query.

DoCmd.SendObject acSendQuery, "Dailyrpt", acFormatXLSX, email.address, , , "Daily Report", "This is today's report", -1, False (email.address would actually be the email address it is being sent to.)

I also have code that will export the query to excel and save it as a file, using DoCmd.OutputTo, where I was able to name it something meaningful to the end user, and include the date.

DoCmd.OutputTo acOutputQuery, "Dailyrpt", acFormatXLSX, "Z:FolderComplete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Dim Foldername As String
Foldername = "Z:FolderComplete as of " & Format(Date, "yyyymmdd") & ".xlsx"
Shell "C:Program Files (x86)Microsoft OfficeOffice14EXCEL.exe """ & Foldername & "", vbNormalFocus

Is there a way to either send the saved (renamed) file or to include the current date as part of the SendObject command?

View 4 Replies View Related

Modules & VBA :: Access To Crash

Aug 21, 2013

So, my database appeared to be working OK yesterday however I occasionally saw an error in my "Update Event" script on one of my combo boxes.
today, now when I try the combo box, I get a immediate crash.If im assuming its the same combo box, here is the code for that box:

Code:

Private Sub MCAcmb_AfterUpdate()
Me.Model.RowSource = "SELECT DISTINCT [tbl].Record, [tbl].Model" & _
" FROM [tbl] WHERE Record = '" & Me.Recordcmb.Value & _
"' ORDER BY Model"

[code]...

I recently added a header...just tried it again and got the error:"The expression After Update you entered as the event property setting produced the following error:Object or class does not support the set of events."however I got it to work by entering VB, adding a space, removing it and then saving and entering the form view the form worked as normal. when i close and reload, i get the error again

View 3 Replies View Related

Modules & VBA :: How To Know If PDF Is Printed From Access

May 7, 2015

I have a hyperlink for a pdf document in my access form.

The user will enter his id and then he access to this form

I want to know when he opens the hyperlink if he will print the pdf file or not

I want to save the name of the pdf file in a table if the user prints the hyperlink document from the form.

View 1 Replies View Related

Modules & VBA :: DOS Commands In Access

Mar 13, 2014

I was quite familiar with DOS commands and was able to create access DBs and write the VBA button code. However that was quite a few years ago and Ive forgotten it all.For every image file in DIR A or subdirectory If that image file exists in DIR B, then delete the image in DIR B.

View 3 Replies View Related

No VBA Modules In Access DB Running On OSX

Jan 7, 2013

I have just installed the windows version of Access 2010 on OSX Mountain Lion using a program called Crossover which works very similarly to WINE. I have found that Access will install fine except for VBA form modules and BAS modules, although there seems to be no indication that they did not install as the entire install progresses fine.

I've put together an invoicing program that was created in Access 2010 in Windows but have transferred it over to Access 2010 installed on OSX. It contains a number of forms with code but when I go to VBE, form code modules are not visible. When I try to view the code for a form I get the following error message: "Microsoft Access failed to create the Visual Basic module. If your database is on a network drive, check your network connection, then try again". I was able to insert a BAS module and create a rudimentary VBA subroutine which ran without error so it does seem able to interpret VBA as per normal.

View 2 Replies View Related

Modules & VBA :: Do Until Causes Access To Stop Responding

Dec 24, 2013

I'm using the following code:

Code:
Private Sub Form_Timer()
Dim LocalTime, StartWindow, EndWindow As Date
LocalTime = Format(TimeValue(Now()), "hh:mm")
StartWindow = #11:46:00 AM#
EndWindow = #11:48:00 AM#
Dim Response

[Code] ....

The intent is to run automated back end maintenance activities while giving the user the option to delay it if they're in the middle of something.

My logic is as follows:

If it's between these two times, ask the user if the maintenance can run.
If user says yes, run maintenance.
If user says no shift the two times to the right and ask again in a few minutes.

As it is written, when I chose no I get an hourglass icon and if I try to do anything else Windows tells me Access isn't responding. I'm guessing that Access is hanging since I've initiated the Do Until and then stalled it by telling it to wait 3 minutes before it goes to the next step. I suspect that if I waited it out, when the new Startwindow hit I would be asked about running the maintenance again.

My issue is that I need the database to remain responsive to whatever the user needs to do while I wait to ask about running maintenance again. Therefore, I don't think Do Until is my answer - at least not the way I've implemented it.

The will ultimately be set on a 10 minute timer interval and start/end window will be 01:00 and 01:15 AM respectively. The times you see above are there for testing so I can see what happens.

View 3 Replies View Related

Modules & VBA :: How To Search For Keywords On Access

Oct 29, 2014

I managed to create a form that is able to search keywords on Access 2007. However, the keyword search must be exact to what is contained in the table.

For example, I stored "red blue yellow" into the database, and I can only search "red blue yellow", "red blue" or "blue yellow" in order to call that data.

How do I make it such that I am able to search "blue red yellow", "yellow blue red" or "red yellow blue"?

These are my current codes:

Code:
Private Sub txtSearch_AfterUpdate()
Dim strWhere As String
Dim strWord As String
Dim varKeywords As Variant
Dim i As Integer
Dim IngLen As Long

[Code] ....

View 6 Replies View Related

Modules & VBA :: Adding A Field To Access DB

Aug 6, 2013

I use the following 3 calls to add 3 fields to an Access db,

Code:

Call subCreateField("tblRootCanalTreatment", "lngMethodID", "dbLong", strPath, 606)
Call subCreateField("tblRootCanalTreatment", "txtReferencePoint", "dbText", strPath, 620)
Call subCreateField("tblRootCanalTreatment", "txtSpaceForPole", "dbText", strPath, 644)

The sub is indicated below,

Code:

Private Sub subCreateField(strTable As String, strField As String, strFieldType As String, strPath As String, lngVersion As Long)

Dim rstSerial As ADODB.Recordset
Set rstSerial = New ADODB.Recordset
rstSerial.Open "tblSerial", CurrentProject.connection, adOpenKeyset, adLockPessimistic
rstSerial.MoveFirst
If rstSerial!lngVersion < lngVersion Then

[code]....

Only the first field ("lngMethodID") gets created. The other two fields ("txtReferencePoint") and ("txtSpaceForPole") do not get created. If I exit the db before each sub call then all fields get added. Do I need to add some "refresh field" action or other action.

View 14 Replies View Related

Modules & VBA :: How To Add Pictures Into PowerPoint Using Access

Aug 17, 2013

I am using access 2013 to make a PowerPoint presentation based on the data in a query. I know how to do that much using VBA but I am also trying to make a slide with a picture on it from a saved location.

Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
On Error GoTo err_cmdOLEPowerPoint

[code]....

At the moment I am not worrying about adding the data as I know how to do this and had it working before - its just adding the picture to the slide.

View 2 Replies View Related

Modules & VBA :: Access - Get SubForm Datasheet Value Of Row?

Feb 27, 2015

I have a subform which is created with textbox and some command button in the top of the window, so this will simulate like a Datagrid.

[URL]

This is how it looks my datagrid when it fills from a Query.

[URL]

What I want is when I select a row from my subform, I want to Click the button "Cambiar", and get the value of the machine selected.

[URL]

View 4 Replies View Related

Modules & VBA :: If And NZ Statement Not Working In Access?

Jul 8, 2015

why this IF and Nz statement in my code below is not working. I know the me.txtrefNo value is "" (null) on a form field with property set to General Number. Therefore the Nz statement should return a "0" as I specified making the statement true as in 0 = 0 and then execute the actions below to generate a reference number however this it now happening as it's rendering the if statement as false and showing me the message " Whats going On?" which is after the else statement.

Code:
If Nz(Me.txtrefNo, 0) = 0 Then
Me.txtrefNo = DMax("[refNo]", "[R_P_Data_P]") + 1
tmpRefNo = Me.txtrefNo
'testing variable value
MsgBox (tmpRefNo)
Else
MsgBox ("What's going on?")
End If

PS. Does this have anything to do with the table field format that the me.txtrefNo value will be saved to?

View 2 Replies View Related

Modules & VBA :: Export To Word From Access

Sep 26, 2013

I'm trying to create an export to word but am having some trouble. I keep getting the following error;

Run time error '91'; variable or object of With block not defined.

This error occurs at Set TblWord = docNew.Tables.Add(Selection.Range, 3, 5)

I have a feeling its 'Selection' that is causing the problem but I can't work it out!

Code:
Dim AppWord As Word.Application
Dim DocWord As Word.Document
Dim TblWord As Word.Table

[Code]......

View 4 Replies View Related

Modules & VBA :: Access Not Responding After Procedure

Mar 21, 2014

This is a real conundrum. The following procedure works well the first time through but on subsequent times the database just goes into "Not Responding" mode and has to be restarted. I have tried putting delays in but with little success.

The idea of the procedure is to rename a query, "Daily Logs" to include a specific date "TransDate" so that when the query is sent via Outlook the Excel file name appears for example as Daily Logs 21-03-14.

DoCmd.CopyObject "", "Daily Logs " & Format(Me![TransDate], "dd-mm-yy"), acQuery, "Daily Logs"
DoCmd.SendObject acQuery, "Daily Logs " & Format(Me![TransDate], "dd-mm-yy"), "Excel97-Excel2003Workbook(*.xls)", "someone@dorsetglidingclub.co.uk", "", "", "Daily Logs " & Format([TransDate], "dd-mm-yy"), "", True, ""
DoCmd.DeleteObject acQuery, "Daily Logs " & Format(Me![TransDate], "dd-mm-yy")

This procedure might seem clumsy but was the only way I could think of the achieve the objective.

View 10 Replies View Related

Modules & VBA :: Save Workbook To Access Db?

May 6, 2014

I have some vba code that exports the results of a query to a specific excel workbook. Code in this workbook then takes the exported data to "fill out" areas in the workbook. My staff will then use this workbook to perform analysis on a project. After they have completed the analysis, they will then save the excel workbook, and another person will then validate this excel and turn it into a PDF to send as an email attachment.

My question is, when my staff saves the excel workbook, is there a way they can save it directly to the access database? If not, would there be a way to use vba to "attach" this excel workbook to the appropriate record in the access db for future use?

View 5 Replies View Related

Modules & VBA :: Access Crashes When Connecting To DSN

Apr 20, 2015

I am connecting Access to QuickBooks with the QODBC. I tried to do this in MS Access 2010 with Windows 7 and it worked fine. Then I tried it on a new computer with MS Access 2013 and Windows 7. Now, when the VBA gets to the line:

oConnection .Open "DSN=Quickbooks Data;OLE DB Services=-2"

It crashes. No message, other than the generic "Access has stopped working" message. I am using ADO for the oConnection. I am not sure what the problem is or how to diagnose it. I have used an ADO connection to connect to Excel, and that worked fine, so my guess is it have something to do with the DSN connection?

View 1 Replies View Related

Modules & VBA :: Send Attachment From Access

Feb 4, 2015

I have a button when pressed that it sends an email from lotus notes and inputs relevant text etc, however I seem to be struggling on how to have an attachment sent with the email. So everytime the button is pressed it will attach a word document.

View 1 Replies View Related

Modules & VBA :: Return Focus To Access

Sep 4, 2013

I have a database which connects to another application (by creating an object) for the purposes of reading/writing data. Part of the code involves creating an instance of this application, and then taking input from the user via an Access form.However, when I load the form, the focus stays with the other application, and the user has to 'click into' the form in order to reset the focus to the form and key the relevant details. Not the end of the world, granted, but frustrating over time and something I'd like to iron out.

I originally had this process in Excel, and used the following code to change the focus back to Excel (so that the user could key directly into the form)

Code:
Dim ExcCap As String
ExcCap = Application.Caption

' ...assorted code, including creating the object to 'house' the other application...

' Return focus to Excel
AppActivate ExcCap

But this doesn't apply to Access as it utilises the Application.Caption / AppActivate method to identify the appropriate window to switch back to. In Access, I don't have a caption to reference.I've tried setting the focus in the Form_Load event but it doesn't bring the form 'to the fore'

Code:
Private Sub Form_Load()
Me.SetFocus
End Sub

View 8 Replies View Related

Modules & VBA :: How To Run A Function From SQL Query In Access

Nov 26, 2013

I started using Access recently and I have an inquiry about VBA codes and sql queries. I have function which has the following signature: RAG(Stability as Integer, DS_SYNC_RATE as Integer, Profile as String) as String.

I would like to call this function in Insert sql query in order to calculate and add a new column to my table. I tried this basic query:

Insert INTO my_table VALUES (RAG(my_table.stability,my_table.ds_sync_rate, my_table.profile))

but it doesn't seem to work...

View 8 Replies View Related

Modules & VBA :: Exporting And Emailing From Access

Jul 18, 2013

i am very new to access, but i can code in excel well.what i really want to do is no how to automatically email a report, query or table. I also would like to be able to export the above three to excel as well. I have worked my way up a little bit but my hair is falling out with how hard this is to achieve. I have come up with the following so far:

Code:

Dim outputFileName As String
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String

[code]...

The above code works a bit, but it only allows me to export tables (dont know how to modify it). It also doesnt open the table in excel properly, it opens excel, but the table doesnt open. I have to go to the location and manually open it.

View 6 Replies View Related

Modules & VBA :: Format PDF Document Sent From MS Access

Sep 23, 2013

Is it possible to format a PDF document created in MS Access i.e. set the document to landscape instead of portrait as in the following code;

DoCmd.OutputTo acOutputQuery, "Query Name", acFormatPDF, "Document Name", False

This PDF document is attached to an MS Outlook e-mail and sent without any intervention from the user. This is accomplished using further VBA code. This code is working at the moment sending both Excel spread sheets and PDF documents but the PDF's require the page formatting before sending. I want to be able to accomplish this without having to open another application such as Adobe Acrobat.

View 3 Replies View Related

Modules & VBA :: Saving Images Into Access DB

Jul 1, 2014

Ok. So I have learned my lesson on saving images into an Access DB. Now I'm using VBA (another good learning experince) to save the images back to a folder. I have a code working that will save the images but I need it to also rename the images after saving.

The section "MyFile = OldFile" needs to reference the rsChild Attachment file name...

Quote:

Private Sub Command859_Click()
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2

[code]....

View 2 Replies View Related

Modules & VBA :: How To Set Up Auto Dialer In Access

Jun 3, 2015

How to set up Auto dialed in Access or know of a link where I can be pointed to. (I assume this will set it up with a modem dialler?)I know you can use the wizard to set in up, however when clicking the button it doesn't pick up the number form the number field in access.Also is there a way of recording calls numbers made, call time and call length in say a table or form in Access?

View 14 Replies View Related

Modules & VBA :: Access 64 Bit Linking Tables

Jul 10, 2013

I have a code for linking tables. It works on Access 32 bit.I modify the code for 64 bit (include PtrSafe after all Declares, etc...)But it doesn't work.When I try to chose database in dialog window, my program closed.

Code:
Public Function GetDbPath(path_name As String) As Integer
Dim i As Long
i = MsgBox("The path to database is incorrect" _
& Chr(13) & "Chose new path?", vbOKCancel + vbExclamation)
If i <> vbOK Then
DoCmd.Quit
Exit Function

[code]...

View 3 Replies View Related

Modules & VBA :: Access Database Getting Blocked For Use

Apr 18, 2014

I have a database split into a front-end and a back-end. The back-end is stored on a shared drive. I have learnt that any user who has only read access to the shared drive and opens the front-end will be opening the database in Exclusive Mode as he'll be unable to create the locking file and would hence be inhibiting all other users from editing the database.

This is a game spoiler. Is it possible to disable this user from opening the database at all. Or can we do a check in VBA if the user has opened it in exclusive mode and then just push him out giving an error message.;

View 1 Replies View Related

Modules & VBA :: How To Set Up Variables When Access Starts

Oct 9, 2013

I need to set some 'global' variables with default values when my Access 2007 database is loaded. Depending on the user etc these values may be modifed after Access starts but defaults need to be set.

I declared the variables as 'Public' in a Module, then put a function in the same Module (to set the default values) then tried to call the function from an "AutoExec" macro, so it's the first thing that runs when Access loads.The macro throws an error - it can't 'find' the function(?)

View 2 Replies View Related







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