Modules & VBA :: Opening Forms Based On Results Of Union All

Apr 13, 2015

I have some code in my database that will open a form based on the result of , I think, a union query.

Private Sub resultbox_DblClick(Cancel As Integer)

'Open report based on the ID from resultbox listbox

DoCmd.OpenReport "ResultsStan", acViewReport, , "[ID] = " & Me.resultbox, , acDialog
'End If
End sub

What I need to do is open one of a number of reports. The report that needs to be opened depends on another value that is passed from the union query - DOCCAT

Being still a bit of a novice I tried...

'If "[DOCCAT]= " & Me.resultbox Like "Standards" Then
DoCmd.OpenReport "ResultsStan", acViewReport, , "[ID] = " & Me.resultbox, , acDialog
'End If

Needless to say it didn't work.

View Replies


ADVERTISEMENT

Modules & VBA :: Opening A Recordset Based Upon A Variable?

Jul 5, 2013

Simple example is I have say 3 recordsets open (they are opened once as they are refered to many times) - they are open early in the form (in this example 3 price lists that are applicable for a customer) (if the syntax of the select is slightly wrong I'm just showing to 'prove' the concept).

Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=1));")
Set rs2 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=2));")
Set rs3 = db.OpenRecordset("SELECT * FROM Prices WHERE (((Prices.ID)=3));")

What I want to do is have a central function that I can pass a list I wish to process/do something with aka. The 3 recordsets are the same except for the where criteria.

private sub GETPRICEFROMLIST(pricelist as long)

dim rs as recordset

set rs = Recordset("rs" & pricelist)
.....

I put the above to show what I'm trying to do but of course that doesn't work There won't be any updates to these recordsets only reading of data.

View 6 Replies View Related

Modules & VBA :: Opening File Based On Directory Location

Feb 15, 2015

When creating an incoming inspection database, I want to set it up so when I am in a form to add data, I want to have a command button where I can pull up the associated CAD drawing based on part number and drawing number. I would like to enter the directory location into a table so I could change it if I need to.

So basically I want to go something like this:

.tblDirctoryLocation
txtDirectory

.tblProduct
txtProductName
txtProductNumber
txtProductCADNo

These tables would not be related to one another as there will only be one record for the directory location and multiple records for products.

Somehow I want the db to assemble file location like this:

“EQuality_DirectoryIncoming” & “ProductNumber_” & “CADDrawing” & “.pdf”
End result: EQuality_DirectoryIncomingProductNumber_CADDraw ing.pdf

Is there any way this could be done?

View 1 Replies View Related

Modules & VBA :: Calendar Entries - Opening Recordset Based Off Of SQL String

Oct 30, 2014

I am currently developing a calendar and am trying to open a recordset based off of a SQL string. When I deleted the Where part of the SQL statement, the code ran fine. So I am pretty sure that the problem lies within the Where part of the code. I use this code to filter my query based on txtTaskTypeID but if the value is null then the query is suppose to return all values. I keep getting Run-time error"3061: Too few parameters. Expected 1".

Code:
strSQL = "SELECT tbl1CalendarEntries.ID, tbl1CalendarEntries.Title, tbl1CalendarEntries.StartDate, tbl1CalendarEntries.StartTime, " _
& "tbl1CalendarEntries.EndDate, tbl1CalendarEntries.EndTime, tbl1CalendarEntries.TaskTypeID " _
& "FROM tbl1CalendarEntries " _
& "WHERE (((tbl1CalendarEntries.TaskTypeID)" _
& " Like IIf(IsNull([forms]![frmProductionPlanning]![txtTaskTypeID])=True,""*"",[forms]![frmProductionPlanning]![txtTaskTypeID]))) "
& "ORDER BY tbl1CalendarEntries.Title;"

View 5 Replies View Related

Opening Two Forms Based On Same Table

Feb 22, 2005

Form #1 allows me to modify/add data to records in Table A.

Form #2 is restricted to displaying (no edit, add, delete capabilities) information from a query that is based on Table A.

I need to find a way to open an instance of Form #2 while in Form #1, but I keep getting the following message...

"The table 'TableA' is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmatically."

Any suggestions for how I can get around this?

The data I want to display in Form #2 is not linked to the record being displayed in Form #1, so a subform will not work.

Thanks in advance!

View 2 Replies View Related

Opening Forms Based On Criteria

Feb 12, 2006

Hello everyone,

I have a problem with opening forms.I have situation with 8 forms (small ones!) which must be open based on values in ComboBox1 and ComboBox2.
Can I do it with Select case (DoubleClick event), and how?

THANK YOU IN ADVANCE,

View 4 Replies View Related

Forms :: Opening Form Based Off Another Forms Combo Box Value

Nov 5, 2013

I'm trying to get a combo box & button to work together. On the main form of the attached database, I just want the button to go to the associated record based off my selection (or entry) in the combo box.

I've tried the following:

- Looked through the Northwind sample database for a close example. Tried my best to replicate the functions but it didn't work
- Looked through other examples posted and tried to manipulate the code to no avail
- Tried using [Forms]![Main Form]![cmbLastName] in both the filter & criteria section of the macro

View 4 Replies View Related

Novice Q: Opening Forms Based On Criteria

Feb 7, 2005

Hi folks,

I have a form with a regular save record command button, however I also want to add in an action to open a second form based on information stored within the form.

So users may be directed to Form.alpha or Form.beta depending on their data.

Can any one help?

View 1 Replies View Related

Queries :: Union Query Not Separating Results

Feb 18, 2014

I have a simple union query that looks like this:

Code:
Select DPTag from tbleqDP UNION ALL select ESGTag from tbleqESG

It is returning all the tags from both tables but putting them all under "DPTag." What I want is two columns in a report. One would have the header "DPTag" and all the values under it would be the tags from tbleqDP and the other would have the header "ESGTag" and all the values under it would be from the table tbleqESG.

What am I doing wrong such that it is returning all the values under the header DPTag?

View 10 Replies View Related

Forms :: Opening A Form Based On Transaction Table

May 5, 2014

I wish to open a form based on the transaction table populate one of the foreign key fields with a selected value from a combo box from the switch board (with going to a mainform&subform). I know how to get the value of the combo box on the switchboard. I just know how to then store this value in the foreign key field. stSelectedCustomer = Forms![Switchboard].[CustomerID] gives me the value from the combo box on the switchboard. I then want to open the transaction form to open a new record and have Customer ID on this form be the stSelectedCustomer storing this value in the transaction table when the user enters values in the other fields.

View 2 Replies View Related

Forms :: Opening A Form And Displaying Records Based On Two Criterion

Feb 24, 2014

OK, I have two forms:

Form 1: Courses

Form 2: Mark Grid

The user select the class from [Combo28] for the unit already in [Textbox named Unit] from Form 1 and wants to list all the students for that particular class and unit in form 2.

I have tried god knows how many different codes. I've been playing with:

DoCmd.OpenForm "Mark Grid", , , "[Text43]=" & Me![Combo28] & " AND [Text17]= '" & Me![Unit] & "'"

But with no luck.

View 2 Replies View Related

Union Queries - Results Showing As Text & Not Numbers

Dec 13, 2007

To cut a long story short, i've got a union query that is a full outer join of 2 tables.

Anyway, the results i have got back needed formatting to no decimal places.

How do i do that?

I've tried leaving it as it is and formatting it in the report, but it still doesn't format and i can't total it up.

It's like it is showing as a text and not number.

Is there a way of converting the result to a number, particularly in a sql query.

View 2 Replies View Related

Forms :: Opening A Form Based On Multiple Tables On A Specific Record

Dec 31, 2014

I have a form "frm_PatientNew" based on table "tbl_patients", this form contains a button "cmd_NewVisit" which is supposed to do the following: opens the form "frm_NewVisit" for recording a new visit for the last recorded patient in "tbl_Patients", I found many approaches depending on DMax and Dlookup and they worked fine just if "frm_NewVisit" is bound to "tbl_Patients", but "frm_NewVisit" is bound to "tbl_Main" which acts as a container for all information (patient data, visit data,service done and service provider), so the form "frm_NewVisit" contains fields from different tables. I wonder if I should create "frm_NewVisit" as unbound form, then adding fields from different tables to it and using vba to populate "tbl_Main",

View 2 Replies View Related

Forms :: Generate Custom Form Based On Query Results

Dec 11, 2013

I'm trying to track daily production at a manufacturing company running many different processes at different locations each running multiple parallel "lines." The tricky part is that the number of lines running and the shift schedules e.g. 2shifts 10hrs/day 4days/week or 3shifts 8hrs/day 5days/week change frequently for each process.

Right now I have a form for process data that specifies the schedule and number of lines running each day. Then I'm running an append query to a "production" table that generates blank production records associated with each item made in each process for the correct shift/line combinations.

Up to now I've been manually changing the date on the append query each time I run it. Then I have a seperate query for each process that pulls out the production records for each day. My problem is that the preferred interface for production data entry is a spreadsheet with the following layout:

--------DAYS LINE 1 DAYS LINE 2 SWING LINE 1 SWING LINE 2
ITEM 1 100
ITEM 2 2250
ITEM 3

which changes each time the shift/line schedule changes for each process. The only way to achieve this layout I know of is a crosstab query which isn't updateable. Ideally, each day the manager will specify the shift schedules and forms will be automatically generated with the correct structure and sent to the process supervisors. I'm open to different form layouts and even redesigning the database completely.

View 2 Replies View Related

Forms :: Sending Email From A Form Based On Query Results

Apr 1, 2014

I have got a form (name: SearchForm) that displays results of a query (name: AircraftSearch). It is a continuous form displaying multiple results of a search done by the query. I need to be able to send an e-mail to multiple recipients chosen from results displayed on the form.

One of the form's field (a text box called: EmailToOperator) is containing e-mail address to an aircraft operator selected by the underlying query. I need to be able to place a check box button (or something similar) that is going to select the e-mail address. The tricky part is to have multiple check boxes allocated for each record displayed on the form and have them working independently.

The second task is sending a one message (via Microsoft Outlook 2010) to chosen multiple recipients (with no attachments) having the recipients' addresses not visible to each other.

View 7 Replies View Related

Forms :: Filter A Report Based On Listbox Selection - Apostrophe In Results

Feb 17, 2014

I use the follwing code to filter a report based on the listbox selection on a form. Below is the code I use, the problem it will error if the results have an apostrophe in the string.

Private Sub FilterDesc_Click()
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.ListCarrier.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 Carrier"

[Code] ....

View 7 Replies View Related

Modules & VBA :: Opening Forms In Datasheet View

May 8, 2014

I have read various answers on how to open a form in Datasheet view from VBA code, but I can't get my syntax correct.

Here is one of my 50 attempts to guess at the format. Removing different components, separators, variables only gets me a syntax error of missing separator or "expected =".

DoCmd.OpenForm ("frm_OrdersHOTHeadersOnlyWORKSHEET", [View as acFormView=acFormDS], , , , ,[acFormEdit])

View 3 Replies View Related

Modules & VBA :: Opening 2 Forms Sequentially On Button Click

Jun 20, 2013

From formA I click on button cmdFormB and I open FormB. From formB I click on button cmdFormC to open formC.

Is there a way to open forms formB and formC by clicking on a button on formA?

View 5 Replies View Related

Forms :: Closing Opening Form With Timer Then Opening Main Menu

Apr 7, 2014

I have a Form opening from Access Options. I would like to close this Form using the Timer. The following is the code I have used but it is not working.

Private Sub Cover_Page_Form_Load()
OpenTimer = Timer
End Sub
Private Sub Cover_Page_Form_Timer()
If (Timer - OpenTime) = 5 Then DoCmd.Close acForm, "Cover_Page_Form", acSaveYes
End Sub

Next question. If I can get this to work can I then use a DoCmd to open new Form within the code above or do I need a new process.

View 5 Replies View Related

Report Design Response Is Slow - Based On UNION Query That Returns 12K Rows

May 20, 2005

I have a front end that is connected to three back end files. The front end is on my local computer while the back end files are on a network drive.

There are a lot of calculations that go into the queries and intermediate queries. For a report, I have based it on a UNION query.

But when trying to design the report it takes about 45 seconds just to do any one thing, e.g.;
- Add Groupings
- Add Grouping Headers//Footer, sorting option
- Add bound textbox
:eek:

Needless to say this is very annoying.
:mad:

The union query itself runs fine (takes about 15 seconds to run) and returns about 12,000 Rows. The union query looks like this (I changed the field names to make it read easier, hopefully);

SELECT a1, a2, a3, a4, a5
FROM qry_A;

UNION SELECT ALL a1, b2 AS a2, b3 AS a3, a4, a5
FROM qry_B;

UNION SELECT ALL a1, c2 AS a2, c3 AS a3, a4, a5
FROM qry_C;

UNION SELECT ALL a1, d2 AS a2, a3, a4, a5
FROM qry_D;

UNION SELECT ALL a1, e2 AS a2, a3, a4, a5
FROM qry_E;

UNION SELECT ALL a1, f2AS a2, tblG.f3 AS a3, tblG.f4 AS a4, a5
FROM qry_F;

One solution I came across when searching the forums was to use an Append Query to append the query results to a table and base my report on that. This does indeed fix the problem.

But what I was wondering if it was is my query design that is causing it to be slow or is it just the fact that I am returning 12,000 rows?
:confused:

In case it matters, I wanted to mention that I cant use the report wizard to create the report. When I select the union query, the fields will be showed for awhile then they just disappear. That in and of itself doesnt cause any trouble since I am creating the report using the design view and not the wizard.

View 7 Replies View Related

Opening Forms Directly (instead Of Opening MS ACCESS)

Apr 20, 2006

Hi All,

Is there a way that when the user clicks on a database file, the form pops up without opening MS Access window.

Thx,

Jatz

View 1 Replies View Related

Opening Forms Directly (instead Of Opening MS ACCESS First)

Apr 20, 2006

Hi All,

Is there a way that when the user clicks on a database file, the form pops up without opening MS Access window.

Thx,

Jatz

View 6 Replies View Related

Queries :: UNION / UNION ALL Query Crashed Access

Oct 24, 2013

I'm having a problem with a UNION / UNION ALL query.It seems there is a application crash fault when running the query that MS are aware of and have issued a hot fix. Unfortunately it will take my IT dept some time to check and install the hot fix If they agree to do it at all.

Problem signature:
Problem Event Name: APPCRASH
Application Name: MSACCESS.EXE
Application Version: 12.0.6606.1000

[code]...

View 1 Replies View Related

Modules & VBA :: Export Union Query To Excel / Delete First Row

Apr 22, 2014

i export a union query to excel by the following code:

Code:
Private Sub Befehl0_Click()
'bersicht aufrufen
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
Dim rst As DAO.Recordset

[code]....

How can i delte the first row of the querry? without doing a new querry?

View 7 Replies View Related

Modules & VBA :: User Input Criteria For Union Query?

Aug 20, 2013

I am trying to get my VBA code to dump a query once the user pushes a button. I have the following code to call up the Excel app.

Code:

Option Compare Database
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long

[code]....

The qry_PP_Errors_Union is a Union query. In this query there is a date field. I would like to be able to to use that date field as a parameter. So I have written this VBA to prompt the user for a Begin Date and an End Date.

Code:
Beep
strBegindatemsg = "Enter the beginning date." & vbCrLf & vbLf
strBegindate = InputBox(Prompt:=strBegindatemsg, Title:="Begin Date")
Beep
strEnddatemsg = "Enter the beginning date." & vbCrLf & vbLf
strEnddate = InputBox(Prompt:=strEnddatemsg, Title:="End Date")

Now the part that I am missing is that I am not sure how to make the "strBegindate" and "strEnddate" the criteria for the union query.

The following is the SQL for my union query.

Code:
SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, UICError AS Error, "Update and Internal Correspondence" AS Category FROM qry_PP_UIC_Error
UNION
SELECT LastName, FirstName, Title, TeamName, WorkOrderNumber, DateCompleted, WorkCode, BIDError, "Bids" FROM qry_PP_Bid_Error

[Code] ....

Without the criteria, my code works for dumping everything out into Excel. However, dumping all the data results in a 7 mb Excel file that requires manual deletion of the information that is not pertinent.

View 3 Replies View Related

Modules & VBA :: Union Query - Automate Date Field

Mar 18, 2014

The statement below is a snippet from a union query and is repeated 6 times within the SQL Statement for various reasons, I have to manually change this every month, again is there i tiny bit of code I can insert to replace the following so that it automatically runs the previous months data.

WHERE ArrivalDateTime >= 'February 1 2014'

View 5 Replies View Related







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