Modules & VBA :: Access - Query When DataSelected

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 Replies


ADVERTISEMENT

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 :: 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 7 Replies View Related

Modules & VBA :: Return Results Of SQL Server Query To Access

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

Modules & VBA :: Count Incrementally Each Duplicate Column Value In Access Query

May 30, 2014

I have a query where I need to incrementally count the repetition of column values and add that value in a new column.

Example:
"Column One" and "RepeatCounter" are fields in a query.

Column OneRepeat Counter
Value 11
Value 21
Value 31
Value 12
Value 13
Value 32

I want to create the outcome in the field "Counter" in an Access Query. I am a novice in Access VBA. I found I can do it in Excel with the formula CountIF. I am unable to do it in Access.

View 9 Replies View Related

Modules & VBA :: Access 2010 / Loop Through Query To Assign A Value To A New Field?

Aug 16, 2013

Using Access 2010: I have a query with four fields: ORG_NAME, PERS_NAME_LAST, CountOfORG_NAME, and BdMbrCount. There are a couple hundred companies in the database with 1-7 people associated with each company. I need to number each person so that they have a number, 1-7 in the MemberCount field of my query.

I have my query connected to VBA code.

I have experimented with code that I have found on the forum, just to see if I could get something to work and I am getting “Undefined function ‘BdMbrCount’ in expression. I am trying to pass [ORG_NAME],[PERS_NAME_LAST] to my function and assign the value of BdMbrCount to a new field in my query, BdMbrCount.

Code:
Function BdMbrNumber()
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("YourBdMbrsRRecognizedQry")
'Set rst = CurrentDb.OpenRecordset("SELECT [ORG_Name],[PERS_NAME_LAST],[CountofORG_NAME], [BdMbrCount] FROM YourBdMbrsRRecognizedQry")
Dim ORG_NAME As String

[code]....

View 14 Replies View Related

Modules & VBA :: Passing Excel Cell Date To Access Query

May 1, 2014

I'm having a rough time trying to figure out how to pass a date to an SQL statement that Excel VBA macro will run. The date is in a cell (A1) formatted as 'm/d/yyyy'. Let's say it's 2/1/2014. I want to run an SQL statement that retrieves data from a table where a field is greater than 'A1'. The table field is a date/time field and has values formatted as 'mm/dd/yyyy'.

I've tried various syntax on the Where but cannot get it to work.
sd = Range("A1")
SELECT [tn].[Date Submitted]
FROM[tn]
WHERE tn.[Date Submitted] > """ & sd & """

This results in the following where clause that does not work.
WHERE tn.[Date Submitted] > "2/1/2014"

View 4 Replies View Related

Modules & VBA :: Passing Variable From Excel To Fire Access Query

Dec 17, 2014

I'm running a VBA routine in Excel that loops through a lot of data. As part of the process, I'd like to pass a variable from Excel to an Access database that is open and have it run a query based on that value.

View 4 Replies View Related

Modules & VBA :: Exporting MS Access Query Into Multiple Excel Workbooks

Jan 16, 2015

I have got an existing query which is exported to excel through DoCmd.Transferspreadsheet. In simple terms the query looks like below:

Group | Client

Group1 Client1
Group1 Client2
Group1 Client3

Group2 Client4
Group2 Client5
Group2 Client6

etc.

As some of the groups contain large number of clients, I am trying to find the code to split groups by pre-specified number of clients and export to excel, as follows:

Group1 - clients 1 to 300.xlsx

Group1 - clients 301 to 600.xlsx

Group2 - clients 1 to 300.xlsx

etc.

View 1 Replies View Related

Modules & VBA :: How To Export A Query To Excel If Access File Is Read Only

Feb 26, 2014

I have an access program that is stored on a SharePoint site. I want to be able to export report to the computer even if I just open the access program as read only. Here's my code:

Code:

Private Sub btnExport_Click()
On Error GoTo btnExport_Click_Err
Dim db As DAO.Database
Dim strSQL As String
Dim qdfTemp As DAO.QueryDef
Dim qryFilter As DAO.QueryDef

[code]...

View 2 Replies View Related

Modules & VBA :: Schedule Auto-exporting MS Access Query To Excel And Email It?

Oct 9, 2014

I know Access can setup an Outlook Task to auto-export query to Excel, but it requires the Outlook to be always open on the user's computer.

Is there an easy way to setup a schedule that can automatically export a query to Excel and this schedule will then auto-email the exported Excel file to an email address every Monday at 5AM for example?

If this can only be done in VBA, any reference I may start with?

View 4 Replies View Related

Modules & VBA :: Criteria On MS Access Query Not Working With Multi-Select Listbox

Aug 22, 2014

I am attempting to filter records using a multi-select listbox, but all records are being returned. Here is my code.

Private Sub btnKeyboxCount_Click()
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

[Code] ....

View 1 Replies View Related

Modules & VBA :: Microsoft Access Database Engine Cannot Find Input Table Or Query

Dec 3, 2013

I have an App that runs a few action queries using:

Code:
CurrentDb.Execute "[My Query Name]"

At some point I get this Error: The Microsoft Access database engine cannot find the input table or query <name>. Make sure it exists and that its name is spelled correctly. (Error 3078).The query is there, I can run it from the DB objects window.Queries run using CurrentDb.Execute earlier in the code.

View 3 Replies View Related

Modules & VBA :: Create And Open Variable Folders With Link Created In Access Query

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

Modules & VBA :: Query Input Must Contain At Least One Table Or Query Error

Apr 22, 2015

All I'm trying to do is a make table (table name to overwrite: "TBL_5_7_RFCs") query via VBA so I can loop through a set of VARs in a table. Here is my code:

Code:

Public Function test_sql()
Dim Conn As ADODB.Connection
Dim RS As New ADODB.Recordset
Dim MySQL As String
Set Conn = CurrentProject.Connection
RS.ActiveConnection = Conn

[code]...

I'll add the loop and array once I get this working but I'm stuck.

View 7 Replies View Related

Converting Access To Access Project Query Problem

Sep 18, 2007

Hello All,

I am working on a project that was started in access, but needs to be moved into an Access project so that It can be integrated with other forms. When I did this I realized that my database queries needed to be changed from Access to SQL code. for example instead of representing a date as #DATE# it needed to be represented as 'DATE'.

However I have one issue that I am having issues with.

I have a query that determines a few collumns by running information through a vb function and returning the result.

The issue is I do not know how to convert this code from Access to SQL so that it will work.

The code is

SELECT Action_Indef([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER]),[LOG_NO]) AS [Action], TESTSTAT.*, Action_date([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER])) AS Action_Date_Field, IIf([DUE]<[WAIVER],[WAIVER],[DUE]) AS Later
FROM TESTSTAT
WHERE [LOG_NO] LIKE '*'
ORDER BY Action_Indef([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER]),[LOG_NO]);

Can someone provide me with a sutible sql equvalent to this code

Thank You
Mike

View 7 Replies View Related

Converting Access To Access Project Query Problem

Sep 18, 2007

Hello All,

I am working on a project that was started in access, but needs to be moved into an Access project so that It can be integrated with other forms. When I did this I realized that my database queries needed to be changed from Access to SQL code. for example instead of representing a date as #DATE# it needed to be represented as 'DATE'.

However I have one issue that I am having issues with.

I have a query that determines a few collumns by running information through a vb function and returning the result.

The issue is I do not know how to convert this code from Access to SQL so that it will work.

The code is

SELECT Action_Indef([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER]),[LOG_NO]) AS [Action], TESTSTAT.*, Action_date([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER])) AS Action_Date_Field, IIf([DUE]<[WAIVER],[WAIVER],[DUE]) AS Later
FROM TESTSTAT
WHERE [LOG_NO] LIKE '*'
ORDER BY Action_Indef([DUE],IIf(IsNull([WAIVER]),[DUE],[WAIVER]),[LOG_NO]);

Can someone provide me with a sutible sql equvalent to this code

Thank You
Mike

View 2 Replies View Related

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 2 Replies View Related

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 :: Run Query B With Variable Input From Query A?

Aug 10, 2015

I am looking for the vba to have a query cycle through using records from another query as the parameter run and export for each of the records on the second query.

Table 1 has information with all clients
query 1 has x, y, z being pulled > client used as parameter
query 2 has the list of clients

Currently I have the coding to run the query and export however I am not sure how to get it to repeat for each client.

Code:
Private Sub CmdInternalReports_Click()
Dim xlApp As Excel.Application
Dim rstDetails As DAO.Recordset
Dim strTab As String
Dim strDir As String
Set xlApp = Nothing
Set rstDetails = Nothing

[code]...

There can be upto 70 different clients or as little as 2 depending on the day. So the Query I have takes a list of the clients that receive the report and runs it against the imported table to only give the ones with data day.

PHP Code:

tblClientReport.Distro 

Is where I have the report via client name linked the the distro list that should be pulled.

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







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