Modules & VBA :: Create Materialized Query In Access
Jan 23, 2014
I need to create a new table in current databases using ADODB whose properties are defined in a lookup table.
Public Function Create table()
Dim cnnDB As ADODB.Connection
Dim myRecordSet As ADODB.Recordset
Dim tblname As String
Dim qry_Issues As String
' Get connection to current database.
Set cnnDB = CurrentProject.Connection
Set myRecordSet = New ADODB.Recordset
[code]....
-How do I make now the new table that does not exist yet with as many columns as set in lookup.
-The new table properties are based on above table.
cnnDB.Close
Set myRecordSet = Nothing
Set cnnDB = Nothing
Exit Function
View Replies
ADVERTISEMENT
Aug 5, 2014
I am trying to set up something to be able to take me to a folder that holds various forms for personnel. I have a query that generates the link for each person. I have tried to set it up as a hyperlink in ACCESS 2013 and it displays as one but doesn't act like one.
I want to be able to click the link and have it open up a personnel folder for that individual. I can't find a MACRO that I can create to do it. Example of my query is that it creates a link K:Main BreakdownSection BreakdownPersonnel FoldersName and the name is the variable part.
My next problem will be to have it create that folder when we have new personnel arriving.
I would also note that I have not worked with ACCESS in many years and much of what I was able to do with 2002 and 2003 doesn't work with the newer versions of ACCESS.
View 3 Replies
View Related
Nov 22, 2013
I am using VBA in Access 2013 to make a PowerPoint presentation using data from the access database. know if it is possible to use Access VBA to create a button in the presentation that runs a procedure itself?
View 1 Replies
View Related
Jan 25, 2015
I found the below link that looks great and works.
[URL] ....
Te only thing is that I don't have much control over it and would like to build something similar as we also need to work with access 2003 (still )Any way to find how the code works (if there is some of it hidden in access)?
View 6 Replies
View Related
Feb 24, 2014
Im trying to create a command that will create a backup of my access database once every week. here is the code I've got so far. it works, but not once a week but every time I start the access:
MsgBox ("Hello! Starting Backup procedure")
Dim DateOfBackup As Date
Dim strSourcePath As String
Dim strSourceFile As String
Dim strBackupFile As String
Dim SQL As String
[code]...
View 2 Replies
View Related
Sep 19, 2013
I have tried to create an MDE database and receive the message "Microsoft Access was unable to create an MDE database" I deleted all unnecessary tables, queries, forms and reports and still receive this message.
how to fix this problem in MsAccess 2003?
View 6 Replies
View Related
Apr 20, 2015
I have a table called Contacts in Access:
ID Email
001 email1
002 email2
003 email3
004 email4
008 email5
010 email6
And I have a table called Data in Access:
ID Date Person Title Yes/No Action
001 20/4 Mr A Consultant
001 20/4 Mr B Supervisor
001 20/4 Mr C Consultant
004 20/4 Mr D Consultant
010 20/4 Mr E Consultant
010 20/4 Mr F Supervisor
What I'm looking for is coding that would start with the first ID number in CONTACTS and see if there is the corresponding ID in DATA. If there is, then I want it to create an Outlook email and have:
1.To field populated with the email address in the CONTACTS table
2.From and CC fields to be my email address
3.The subject line needs to read [ID] "Request" and then today's date backward (e.g. 20150420).
4.The body I need to put some generic wording and then a table with the records from the DATA table (first 5 fields plus the headings).
5. The format of the table etc isn't important as long as it is a table format
If it's created the email I want it to go back to the DATA table and put "Email Created" in the Action column for those IDs.
I don't want the email to automatically send; I only want it to create a draft (as this data needs to be manually confirmed before sending).
If for example it gets to checking in DATA table for ID 002 (and as seen there's none there), I want it to skip creating the email and move on to the next ID.
In the end I would expect to see 3 draft emails open in Outlook ready to be sent, looking something like the below (just 001 below)?
From... my email
To... Email1
CC... my email
Subject: 001 Request 20150420
action the below:
ID Date Person Title Yes/No
001 20/4 Mr A Consultant
001 20/4 Mr B Supervisor
001 20/4 Mr C Consultant
And the DATA table look like this (if only 001 email was created):
ID Date Person Title Yes/No Action
001 20/4 Mr A Consultant Email created
001 20/4 Mr B Supervisor Email created
001 20/4 Mr C Consultant Email created
004 20/4 Mr D Consultant
010 20/4 Mr E Consultant
010 20/4 Mr F Supervisor
I will need to add more data to the CONTACTS table over time, also the DATA table will be different each day so I need the coding to accomodate for both of these possibilities.
View 9 Replies
View Related
Feb 27, 2014
I try to create a cross tab query via SQL.Somehow the below code return me a Run-Time Error '3000'.
Code:
Sub TEST2()
Dim strSQL As String
DoCmd.SetWarnings False
[code]...
View 3 Replies
View Related
Apr 2, 2014
I have an access table and I want the code that will check two columns in the table "EnvelopeType" and "EnvelopeSize" and create headers in Excelsheet automatically. In the attached workbook, like in sheet1 the headers are already appeared, I want this to be done dynamically using vba code so that if new values get inserted in EnvelopeType and EnvelopeSize then we won't have to change the code to display more headers.
Please see attached workbook named Sample and Access table. E.g.
EnvelopeType EnvelopeSize
TNT 2nd Class C5
PP1 2nd Class C5
PPI 1st Class A4
Recorded A4
TNT 2nd Class C5
PP1 2nd Class C5
Recorded A4
PPI 1st Class A4
Recorded C5
With the code it should display following headers in excel sheet:
TNT 2nd Class C5
PP1 2nd Class C5
PPI 1st Class A4
Recorded A4
Recorded C5
View 14 Replies
View Related
Mar 22, 2015
I was beginning to think I had got the hang of creating queries on the fly in VBA. After several hours I have just learned that docmd.runSQL does not work for simple SELECT statements. I'm not going to worry about why that would be. I'm sure there's a jolly good reason.
So... I am able to dynamically create the SQL string for the SELECT statement that I need.
How do I run it? It just needs to return results as a datasheet so I can see them. I'm running Access 2013. I've been searching on this subject for quite a while and found many references to DAO, ADO, ADODAOD, YODELAEYYOUDELAYIO! and other things I don't yet understand ...
View 8 Replies
View Related
Nov 22, 2014
the below code works fine if i run a crosstab on a whole table however if i pass criteria to the crosstab e.g between [forms]![form]![txtstartdate] and [forms]![form]![enddate] it fails and returns null for every field? even though if set docmd.runquery "qryReductionByPhysician_Crosstab" this opens with the relevant data?
Code:
Set db = CurrentDb
Set qdf = db.QueryDefs("qryReductionByPhysician_Crosstab")
indexx = 0
[code].....
View 7 Replies
View Related
Jul 22, 2015
I am trying to create a form button that will automatically email each row of a query result to myself. At first the VBA code worked fine with a standard query. However when I use it with a query that contains a reference to a combobox form such as "<=[Forms]![Reminder]![Monthsleft].[Value] And >=0" I get the 3061 run-time error and "Too few parameters. Expected 1." I have included the VBA code below.
Private Sub Command9_Click()
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String
[code]....
If you intend to renew the lease, terms and conditions will need to be submitted for ECC for approval (regardless of changes or not in lease rates). If the terms have yet to be confirmed, it is important to begin the negotiation process as soon as possible with a target to provide the ECC submission at least two months prior to the commencement date of the renewed lease. To ensure sufficient time for ECC approval before the contract expiry date, please prepare the ECC paper and obtain necessary endorsements. Submission details can be found here. The ECC submission template and PSD Questionnaire could be found from this link
DoCmd.SendObject acSendNoObject, , , _
sToName, , , sSubject, sMessageBody, False, False
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
View 2 Replies
View Related
Apr 14, 2008
Hallo,
I need your guidance to do the following;
On a click of a button from the Form the following should execute.
I have created 50 queries. Each query has more than 1000 recordsets.
1. I want to count the number of rows for each query (50 queries = 50 different values)
2. create one table and populate those 50 different values into the table
3. Using those values in the table; a Stack column chart has to be created.
In simple explanation; on a click of a button the data should be processed and chart has to be created.
Just a tip will also do to try on my side.
Thank you in advance
View 1 Replies
View Related
Nov 3, 2013
I have problem to create Stock query in Access 2013..I want to sum Purchasing numbers base ItemName in Purchasing table by query .. but i found error in summing?
View 4 Replies
View Related
Jun 18, 2013
I'm using Access 2007.
So far I have a Multi Select enabled list on which the user selects the serial numbers they want. They then click the "Report" button which will trigger a query based on the selected serial numbers to create a report on those serial numbers.
I have the code for the multi-select list working already. It creates a string of comma separated values that are the serial numbers which are selected in the list. Somehow I need to pass this string to my query so it can use it as a filter.
Here is some of my code:
Code:
Option Compare Database
Option Explicit
Private Sub Form_Current()
Dim oItem As Variant
Dim bFound As Boolean
[Code] ....
Here's my current query in SQL:
Then finally how to I get the query to execute and create a report based on all of this?
View 11 Replies
View Related
Nov 23, 2013
does access have the ability to create a query where all records are present, all fields are present, yet some data within some fields aren't displayed?
View 10 Replies
View Related
Jun 7, 2013
I am trying to work with Access 2010 to do some pretty simple stuff. I have two tables, one with around 500k rows, the other with around 150k rows. There aren't too many columns, less or around 20 for each table.
I am just trying to do a simple inner join and then create a table but every single time I do it gets about 20% done on the status bar in the bottom right and just hangs. The query itself takes no time to run but it can't create it as a table. Same thing happens if I try to export the query.
View 2 Replies
View Related
Aug 11, 2015
I use Access 2013. Is there an easy way to do the following: I have a contract that starts on eg 01/07/2015. Tenant has to pay 100 each month. Is there a way to create a query/table/... where access automatically makes a due date? EG: Joe needs to pay me 100 each month, starting 01/01/2015 until 31/12/2018.
This means:
01/01/2015 - due 100 from Joe
01/02/2015 - due 100 from Joe
...
01/12/2018 - due 100 from Joe
View 1 Replies
View Related
Feb 17, 2015
trying to create an update query to Budget table using the Access Design View:
Field: PctSls (in tblBudget) Update to: [Expense] / [Sales]. The update query always returns 0. However, if I create a Select query using the same calculation, the correct results is displayed. PctSls is defined in the Budget table.
I haven't worked with Access (2003) for several years but this seems too simple to be causing me such frustration. (Was only a casual user even then).
View 6 Replies
View Related
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
Mar 3, 2015
I have a Form, with a SubForm as Continous Form in DataSheet.
Main form: frm_bitacora
SubForm: sfrm_bitacora
When I select a row from sfrm_bitacora I have the code:
Code:
1. Private Sub Form_Click()
2. MsgBox Me.id_report.Value
3. End Sub
So it shows me the value from the fieldname from the table "tb_machine".Now in my main form, in the footer detail, I have some fields that are from tb_report.What I want is when I select the value from the datasheet, in the footer detail change the values as a query, I mean, I want to return the values from tb_report depending on the selected data.
Note: tb_report my primary key is "ID_Report". Note: tb_machine my primary key is "Machine_name", but I also have a column named "ID_report" in my logical mind I made this to connect both tables.
View 3 Replies
View Related
Feb 14, 2015
I have the code below which creates an email to Outlook.
I would like to use CDO to email but can not figure out how to incorporate CDO code into this
Private Sub Command68_Click()
On Error GoTo Handler
If DCount("[dob]", "[cpp12q]") = 0 Then
MsgBox "There are no records to send"
[code]....
View 5 Replies
View Related
Feb 17, 2015
I have some code that will connect to a database and the analyst name from the table. the name is stored as "Peter Cetera" and it would need to change it to "Cetera, Peter", this way I can paste it inside outlook email (happens via vba).
I use the below code to catch the name from the database:
Code:
Sub FindAnalystInDatabase()
'Declaring the necessary variables.
Dim con As Object
Dim rs As Object
Dim AccessFile As String
[Code] ....
The first value returned is the BIN nr and the second is what is interesting form me.
View 6 Replies
View Related
May 28, 2014
I have an Access 2010 application that talks to SQL Server. Part of the application creates tables on the SQl Server and inserts data to it (I know SQL Server has its on data inport/export wizard and bulk insert capabilities but for reasons outside of my control it needs to be done from Access). So I have a connection to the SQl Server and i have VBA that happily executs SQL statements on the SQl Server. The problem is I want to return a recordset from the result of a SQL query issued to the SQL Server. The idea being to check for the presence of tables already created, and if so, append to the already existing table, otherwise if it does not exist, create it and insert data to it.Ive tried the following code but it seems no recordset is being returned:
Set objConnection = New ADODB.Connection
objConnection.Open "DRIVER={SQL Server};SERVER=10.200.3.14;trusted_connection=yes; DATABASE=" & Me.Combo54
strSQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = '" & Me.Combo54 & "'"
strSQL = "USE " & Me.Combo54 & " " & strSQL
Set Rst = cmd.Execute("USE " & Me.Combo54 & " " & strSQL)
View 1 Replies
View Related
Nov 5, 2014
come up with the below code to create PDF documents based on a query. It has been working great but I have a change that I need to make and can't figure it out. The code below creates all the documents in one folder "serverD$DocumentsInvoices" but I need it to create a separate folder for each PDF so that the file (Invoice1234.pdf) will be in the folder (serverD$DocumentsInvoicesInvoice1234Invoic e1234.pdf). That folder does not exist, so I need to create it and then save the PDF into it.
Code:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("Invoice_Report")
Set rst = qdf.OpenRecordset
[code]...
View 3 Replies
View Related
Nov 6, 2013
my parent form has two subforms. when the user double clicks a value on one subform it populates the first blank field in the other subform. I created a code for the double click on the subform
Code:
Forms!frmeventbuild!Form.frmBUILDsub.EMPLOYEE.Value = Me.FULL_NAME
View 2 Replies
View Related