Forms :: Use Query Name Variable Instead Of Contents Of Name
Apr 19, 2014
I have defined a recordsource based on a predefined query. Now I intend to use the SQL statement which works to produce other recordsources based on other queries. More concretely here is my code as of now:
Code:
Dim J1 As Long
Dim SQLRecordSource As String
J1 = Forms(ParName).MemID
SQLRecordSource = "SELECT DISTINCTROW [MembersTbl].* FROM [MembersTbl]" & _
"INNER JOIN [ActiveMembersQy] ON " & _
"[MembersTbl].[MemID] = [ActiveMembersQy].[MemID] " & _
" WHERE [ActiveMembersQy].[MemID] = " & J1 & ";"
In the future instead of writing it like this:
Code:
Select Case QryName
Case "NonMembersQy"
SQLRecordSource = "SELECT DISTINCTROW [MembersTbl].* FROM [MembersTbl]" & _
"INNER JOIN [NonMembersQy] ON " & _
"[MembersTbl].[MemID] = [NonMembersQy].[MemID] " & _
" WHERE [NonMembersQy].[MemID] = " & J1 & ";"
[Code] ....
I wish to write it like this (which does not work):
Code:
SQLRecordSource = "SELECT DISTINCTROW MembersTbl.* FROM MembersTbl" & _
"INNER JOIN QryName ON " & _
"MembersTbl.[MemID] = QryName.[MemID] " & _
" WHERE QryName.[MemID] = " & J1 & ";"
Is this possible ie put the name of the variable that holds the name of the query in quotes or sometimes put the name of the query instead of the contents of the name. If there is a contents function for variables in VBA that can be used by I doubt whether it exists.
View Replies
ADVERTISEMENT
Apr 27, 2015
I'm trying to include some text and the contents of a date field but having trouble with the syntax.
It wont display the contents of the date variable
I have
"Effective Date = " & #" & Me.DebtPrincipalDateFld & "#
I've tried a number of combinations and searched all over but to no avail
View 2 Replies
View Related
Aug 20, 2014
I look at a lot of files to see when they were last updated. I wanted to write a generic procedure to manage that so ..
Code:
Public fDate As Variant
Public vField As String
Public vFile As String
'GTSdata
vField = "txt_gts_data"
[Code] ....
What I hoped Me.vField would do is update the date field [txt_gts_data] on my form with the date the file was last saved.
i.e. me. txt_gts_data = fDate
What actually happens is the variable vfield gets updated from "txt_gts_data" to 19/08/2014 then later code falls over because the fieldname is lost .
Me.[vField] corrects itself to me.vField (and does not work)
Me!vfield falls over (cannot find the field vField, not surprising J)
How do I say update the contents of the variable, not the variable itself?
View 7 Replies
View Related
Feb 23, 2015
I want to use a variable from a form to a query as a criterion. but how?
View 1 Replies
View Related
May 31, 2014
The VBA code I have at the moment:
me.Results.Rowsource = "SELECT car, title, FROM dbo_inventory"
Is it possible to add a variable to a specific row in listbox using the code above? In this case the price?
View 3 Replies
View Related
May 14, 2015
I have a requirement that will need three cascading combo boxes - the second box should only display the contents that match or are relevant to the first combo box, etc.The title of the YouTube video is:
Microsoft Access pt 9 (Cascade Combo Box)
It seems the first and second combo boxes cascade and works fine. However, the third combo box remains blank after the second combobox selection has been made.
I have three tables: Customer, CustomerSubOrg, and PORs. I have setup lookup fields that are using Primary keys for two of the tables (CustomerSubOrg and PORs). However, I ensured that the primary key fields display as the "Names" of each instead of the numbers. I also ensured I went back and changed their data type to "Text" instead of "Number" so the text appears (which seems to have worked for box #2).
How to get the third combobox to display its contents? I've attached some additional screen shots below. I know the problem is within the second combobox -- perhaps the query needs some adjustment?Unfortunately I cannot attach images yet since I am now. But I basically created two queries and used them each for the second and third combobox.The comboboxes on the form:
Customer
Sub Organization
POR
The Suborg query looks like this:
Table: CustomerSubOrg
First Column:
From field SubOrg
From table CustomerSubOrg
Second Column:
From field CustomerID
From table CustomerSubOrg
Criteria [Forms]![frmMain]![cboCustomer]
The POR query looks like this:
Table: PORs
First Column:
From field PORName
From table PORs
Second Column:
From field SubOrgID
From table PORs
Criteria: [Forms]![frmMain]![cboSubOrganization]
Why wont the contents from the third combobox appear?
View 4 Replies
View Related
May 11, 2015
I have five list boxes set to a table in my database. Here is what a few rows in my table look like...
ID IngredientName IngredientType Cost
1 Ham Meat $1.23
2 Beef Meat $3.45
...... ....
27 Lettuce Vegetable $0.22
28 Onion Vegetable $0.12
..... ....
38 Mayonaise Sauce $0.13
The five listbox controls each show the list by the IngredientType, so one listbox shows vegetables, another Meat, and so on. Multi-select is turned on for each listbox. Here is what I want to do: In the form I want to have a subform that will show what the user clicks in listboxes. This running list, with an extra column next to it that will accept a number. Example: say the user selects 'Ham' from the meat listbox. The subform should then show 'Ham' and a space next to it where he can type an integer (allowing for more meat).
Subform:
Ham | 2
Lettuce | 1
Mayo | 1
Subroll | 1
If the user de-selects the item in the listbox I'd like the subform to delete the item from itself.
View 13 Replies
View Related
Aug 14, 2014
I have a drop down box where I select a Retailer. When this choice is made I want the last invoice entry to appear in a text box. I have attempted this by creating a query which contains the top 1 invoice in descending order. My dropdown box Event updates a hidden List box using List677. Requery and List677 has a SELECT statement in Row Source
So far so good this bit works
I want to use this value as a default in a Textbox. I thought I could use the same trick to populate the Textbox as I did the Listbox so i tried Text232. Requery after the List677. Requery in the Event above. But no it does not update. The only time the textbox updates is if the Listbox is in Focus and as I said this List box is Hidden. How can I get the textbox to change in real time... I would use the Listbox but i need to be able to change the value of the contents to run reports, I just want a default value.
textBox Default Value: =[List677]
textBox Control Source: =[List677]
List677 Row Source: SELECT LastInvoice.Invoice FROM LastInvoice;
View 1 Replies
View Related
Mar 2, 2014
I'm trying to have a cell display the information from which ever cell the cursors is on.
I am trying to use (Master Info / Child info) for a subform but would like the Master cell link to where ever the cursor is.
Is this even possible?
View 10 Replies
View Related
Aug 8, 2013
I have a combo box containing "ProgramType". If "DDI" is selected from this combo box, I would like it to open up another combo box containing the contents from "tblDDI". Then I would like the selection to be transferred to "ProgramType". Is this possible?
View 5 Replies
View Related
Jul 17, 2013
I seem to be having an issue with a split form I've been working on. I created this split form on Monday and it was working just fine but today, I have added a couple minor text boxes. Since then, I can view the form contents in Design View but when I switch to "Form View" or "Layout View", it's all gone minus the logo in the top left corner and the title for the split form.
View 12 Replies
View Related
Oct 2, 2013
I am developing a form whereby the user types a single character or a sequence of characters into textbox and a query WHERE clause is compiled upon each character being entered.
The query is the Row Source of a listbox which I requery upon each change in the text box contents.
In the Change event I cannot access the new contents of the textbox until focus moves to another control and then back to the textbox. This is not how I expect this event to work.
View 3 Replies
View Related
Aug 10, 2014
I have a field on a form that is the results of a dlookup to a table.field. I want the value to be updated when I execute a button that is running a macro. How do I do this automatically, and not have to hit the refresh button?
View 5 Replies
View Related
May 17, 2014
I have a form that contains one WebBrowser Control. In this WebBrowser control I interact with the Google Maps API to produce a map.
I would like to save the contents of the WebBrowser Control (Google Map) to an image file. I have not been able to figure out how to do this.
The WebBrowser Control takes up all the space in the form. Perhaps the contents of the entire Form can be exported to an Image?
View 2 Replies
View Related
Apr 19, 2013
I am trying loop through a datasheet so that I can copy the contents of one field into another form.
I have tried using the bellow code to do this on a button click event. However when i run it I get an error telling me that the object doesn't support this property or method. Im not quite sure what this means.
Dim rst As DAO.Recordset
Set rst = Forms![Roll Out - Site Form]![Roll Out - Sign items pick list].RecordsetClone
Do Until rst.EOF
[Roll Out - Sign items added].Form![Code] = [Roll Out - Sign items pick list].[Form]![Item Category]
Loop
View 6 Replies
View Related
Feb 22, 2006
Hi,
I have some queries that I created in 97 and convert to Access 2000.
However, when I go to query DESIGN view, I would like to see all the contents of long functions (iif) that I wrote for some fields as a result of running the query, but each field only shows a portion of it (as if it was truncated). I also use the "Zoom..." of that field or Shift+F2, still the same thing, only shows portion of it, the last portion was truncated.
Do any of you know HOW to show all, so I can check and revise if I need to, pllllllease.
Thank so much,
View 1 Replies
View Related
Jun 11, 2015
I am using the following code to export query results to Excel.
DoCmd.OutputTo acOutputQuery, "QueryName", "ExcelWorkbook(*.xlsx)", strFileName & ".xlsx", True, , , acExportQualityScreen
This command is intermittently erasing the query contents (the stored query remains in the database however is empty)
?!?
Query is pretty basic / essentially as follows;
SELECT
FROM
WHERE (Value Criteria, Form Reference Criteria - combination of ANDs and ORs)
GROUP BY
Don't think it matters but on the same form that is calling this acOutputQuery command, I have a field with its control source being set to:
......ControlSource = "=" & DCount("*", "QueryName")
Why its occurring, debugging and code watching isn't showing me why its happening.
View 2 Replies
View Related
Mar 24, 2008
Running 2007
I never ran into this problem before.
I have a qry, with showing totals (group by). One of the fields is called comments, which is a memo field. I am only seeing partial comments.
When I redesign the query and take out the "totals", I see the entire comments.
Is there a fix to this?
View 4 Replies
View Related
Feb 3, 2014
I have a parameter that I need to get a table contents between dates. In the query:
Birthdate: XXTable: criteria as follows: Between [Enter Start Date] and [Enter End Date:]
When run it gives me the Error - ! This expression is type incorrectly, or its too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables
I have tried almost everything. The formatting of the Birthdate is x/x/xxxx or shortdate. Will this affect the input thus affecting the outcome of the query.
View 4 Replies
View Related
Apr 16, 2013
I am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.
The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".
I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.
Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.
View 2 Replies
View Related
Jul 8, 2013
Error 91 - Object variable or With block variable not set
I am getting this error telling me that an object variable is not set.
I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?
View 14 Replies
View Related
Oct 3, 2014
This code runs fine the FIRST time, however trows up a message the SECOND time it is run.
The error is on the line ".Range"
I am trying to sort records which have been exported to Excel.
Dim LR As Integer
LR = 5
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set wbRef = xlApp.Workbooks.Add
With wbRef
wbRef.Activate
.Worksheets("Sheet1").Activate
With ActiveSheet
.Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes
End With
end With
View 3 Replies
View Related
Jun 10, 2005
:D
I have a form set up where a user chooses a page tab. Either statistical reports or detail reports. Then they have to choose between 2 toggle buttons. Candidate or hire.
So a user chooses detail, then candidate. An option group below that shows the different groupings of detail candidate reports that they can choose.
A couple of examples - detail report of candidates by office applied to, department, application source etc.
Once that is chosen a button is visible to continue. Now they are taken to the appropriate form. This is done by a global variable gstrformname defined in the afterupdate of the group option that they chose (office etc.)
Once they click to continue to the criteria form, they are choosing the criteria. (for example purposes) the choice below takes the user to a criteria form for choosing an application source ( email, monster.com etc) or click a button and all types are given. I have all of that set up. But now I want to change what report the command button is opening, to a variable. A variable that would be set by the below form when the type of report and grouping for the report are chosen...that defines a certain report.
I specified on this main report menu that it is a candidate report that I want, but when I get to the criteria form, I need a way to pass that choice on. I am not sure how to best do that.
I am trying to avoid making 2 copies of the same form 1 for candidates and 1 for hire. :crazy: I undertstand that I should pass a variable here.
So basically on the main form they choose candidate or hire report, then they choose group. The grouping information tells the command button what form to open (the application source criteria form, the office criteria form, etc). The thing is, this form is the criteria for the candidate report and the hire report. The command button on the criteria form would ideally be -
docmd.previewreport gstrreportname, acpreview
my question is, how or where do I define, from the point that they choose candidate or hire, to the next form, that they want the candidate by office or hire by office report? (define the gstrreportname variable as one of those too.)
Make sense?
Here is a pick of the report form (menu)
http://www.geocities.com/misscrf/reportmenu.jpg
For the afterupdate of the frame for the grouping of the report, I have a select case. In that I define gstrreportname for the report it is, if the choice goes right to a report. If it goes to a form first (for criteria), I define that form with a global variable gstrformname. Can I also define the report there (gstrreportname)? If I do that, will the criteria form know that? Even if I close the main report form?
I hope someone understands me! :shrug:
View 5 Replies
View Related
Aug 8, 2006
Hi Everyone,
I'm trying to pass a variable called MyFilter between forms but am having problems. I have created a Module and declared MyFilter as a public string.
The original code in my first form is:
Private Sub Command65_Click()
Dim MyFilter As String
If Me.Filter = "" Then
MsgBox "Please apply a filter to the form first."
ElseIf Me.Dirty Then
' Make sure the record is saved
RunCommand acCmdSaveRecord
Else
MyFilter = Me.Filter
DoCmd.OpenReport "Temp", acViewPreview, , MyFilter
End If
End Sub
How to I change this so that it now stores the value in the Public variable instead of the Private one which it is doing above?
Thanks,
View 5 Replies
View Related
Aug 8, 2013
I have a form with 48 unbound text fields name txt1 to txt48.
These are to represent 24 hrs in half hours, to visually represent the hours capacity of my workshop. Now if I choose a date, which is say Monday, I check my settings, and see that the workshop has a capacity of 15 hrs on a monday. Now I would like to in a loop set the backcolour of the remaining fields to red.
Something like for I = 15 (workshop capacity) to 48
me."txt" & I.backcolour=1111
next I
View 3 Replies
View Related
Feb 21, 2014
Is there a way to use a variable instead of a form name?
e.g. FRM1 is a form
Forms![FRM1]!textbox1.SetFocus
Instead of FRM1 , a variable is used which can be any other form name.??????
View 10 Replies
View Related