Selecting Existing Table Name Using Form's Combobox For A Query

Dec 12, 2006

Folks,
can someone help me on this? I am not sure why the select query inside this procedure is not working. Here is the that routine:

Public Sub temp()
Dim strDocName As String
Dim strTableName As String
Dim strTbl As String
Dim aot As Access.AccessObject
Dim strSQL As String
Dim rpt As Report
Set rpt = CreateReport

strTbl = Forms!frmSearchBoilerGuar!cboTypeOfGuar

For Each aot In CurrentData.AllTables
If aot.Name = "strTbl" Then
strTableName = strTbl
End If

Next aot

strSQL = "SELECT tblProjts1.chrProjectName, tblProjts1.chrBlrPropNum, " & _
"strTablename.memGuranItem , strTableName.memLDs FROM tblProjts1 " & _
"FROM tblProjts1 LEFT JOIN strTableName ON" & _
"tblProjts1.intProjectId = strTableName.intProjectId"

rpt.RecordSource = strSQL
strDocName = "rpt"

DoCmd.OpenReport strDocName, acPreview
End Sub


Basically, I am trying to select a table name from the combobox and then use that table name for my query. Then I want to use that query as a recordsource for my report.

Any help is greatly apprecited.

Shan.

View Replies


ADVERTISEMENT

Selecting From Table In Form Creating New Entries As Opposed To Using Existing

Sep 18, 2012

I have setup a simple access database consisting of 3 tables

Volunteer
Id (PK)
Name

Job
Id (PK)
JobName

Link
Id (PK)
VolunteerId (FK)
JobId (FK)

There is a one to many relationship between Volunteer and Link and a many to one between Link and Job

I want to create a form from which I'll select a Volunteer Name and then choose a JobName from a list box of options and have it create an entry in link with the id of the volunteer selected and the id of the job selected

So let's say there are 5 entries currently in the Job Table.. let's call the JobNames A,B,C,D and E.

In my form I select my name from the list (sourced from volunteer.Name) and then select B from the dropdown. My desired result would be a single entry gets created in Link with VolunteerId = 1 (representing me) and JobId = 2 representing the selection of B. Problem that I am having is that after I select B in the dropdown it creates a new record for B in Job and the Link table gets updated with that JobId as opposed to simply using the one that was already in the table.

View 1 Replies View Related

Duplicate Form After Selecting Value From Combobox

Jul 7, 2012

I'm pretty new to Access 2007. I have a form and in it there are data entry records including a combobox.

I'd like to select a value from the combobox, say "1" and when I do I would like all the information on that form to be duplicated in a new form.

I'd also like a message to pop up saying that info has been duplicated and that the user must update some of the fields.

View 1 Replies View Related

Forms :: Enabling Some Form Controls After Selecting From Combobox

Jan 27, 2014

I have combo box in a form. I want to enable (to highlight) some controls in the form after selecting any value from my combobox.

For example, There are three values in the combobox. And :

When I select value1, I want an unbound combobox1 to be enable (This combobox is synchronized with a bound combobox2). So when this unbound combo is enabled, its synchronized bound combo should also be enabled.

When I select value 2, it should do the similar action on a different unbound combobx3 (which is synchronized with a combobox4).

View 11 Replies View Related

Forms :: Combobox On Navigation Form Header - Query Table To Show Right Info

Mar 24, 2013

I created a navigation form on which I put a form call [frmAnimal Setup].

I then placed one combo box on the Navigation frm Header. I have bound it to its source and it actually queries the tbl and show the right info. However when I select one, it will not let me.

In addition, [frmanimal setup] will not allow me to select a breed although it does query the tbl and shows the right information.

View 1 Replies View Related

Selecting From Combobox Into A Code

Aug 18, 2005

HI,

I have an input form on which I have a combobox.
The user can choose from the list of products. However, I want to use this input in a code and I need the productid to work with in the code. How can I arrange it that when the user selects, they can see the name of the product and the id (not necessarily), but once the input is chosen only the id serves as input and thus in my code I only use the id ( number)???
Stacey

View 2 Replies View Related

Selecting Memo Field From ComboBox

May 29, 2005

Hi All,
I am not sure if this is an easy one or not..
I have a field in a table named Stock_Alias. This field was originally set as a Number field. I have a combo box on a form, which contains the Stock_Alias numbers. When a number is selected, the remaining fields are shown in text boxes.
I have had to change the Stock_Alias field to a memo, to incorporate Numbers & Characters.
I cannot seem to hit on the right code to get the same results as i did when the field was a number field..


This was the code I was using to select the field as a number...

Private Sub Cmbo_Stock_Alias_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Stock_Alias] = " & Str(Me![Cmbo_Stock_Alias])
Me.Bookmark = rs.Bookmark

End Sub

View 4 Replies View Related

Selecting Multiple Items On Combobox

Nov 23, 2006

Hello to all .

Have you got any idea ?

I have a List Box in a table and it is set to permit multiple items selection
from it .

The fact is I can select, as I wanted, multiple items from it through
the Form but when I go to the correspondent table to see the results
the selected data from the List Box isn't there .

Note all data selected from the List Box is visible trough the Form but
not the table .

Has this problem anything to do with mismatch in data type configuration on the table ?


Lots of thanks in advance

Miguel

View 1 Replies View Related

Forms :: Selecting Fields In A Combobox Where ID Matches

Nov 24, 2013

In my Patients table i have a field called PatientID (AUTONUMBER) as my primary key I hve another problem. Is this possible as i hve been trying for two days now. I hve tried a lot of ways but i cant get it to work right. I have a table called dependents. ID , PatientID,,Dependents,DOB,Age id being the PK AND PatientID as a number I have a table called vitals. with ID,PatientID,PatientName( which is a dropdown of Dependents), hpp,sats etc. (This is a subform in datasheet style in another form)

In my table vitals i have the follwing for PatientName . comboxbox.

SELECT Dependents.Dependents, DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd")) AS Age FROM Dependents;

So it selects fine in a dropdown like John 48, smith 36.

The problem i have is that it selcts all the records irrespective of PatientID.

View 14 Replies View Related

Forms :: Linking Existing Form To New Table

May 1, 2015

Each month I receive a new excel spreadsheet (alpha Roster), Last month I created a form so that I can track certain things off of the Table (spreadsheet), I just received the new Spreadsheet for this month and was wondering if I can use the existing form and how hard it is to link it to the new spreadsheet? Is that even possible? I don't want to have to re create the form every month, I would like to just bring the new alpha roster in and be ready to work.

View 4 Replies View Related

Query Pulling A Column Not Existing In The Table

Nov 6, 2007

Is there a way to specify in the query sql, if column XX exists in a table, pull it, if doesn't exist, create a blank column "XX" ?

View 6 Replies View Related

Adding New Field To Existing Table And Form - Getting Error

Jun 8, 2014

I'm trying to add a combo box field to an existing table and form. I added the new field to my existing table and set it up as an combo box added my row sources. Then added the new field to an existing form and now am getting a error stating "The record source "Table name and added field here" specified on this form or report does not exist. When I just make the new field a text box instead of combo box it works just fine.

View 2 Replies View Related

Update/Change Existing Data To New Table With Query?

Feb 17, 2008

i'm a Access novice. I have tables with existing data in numerical form, and would like to know how I can use Queries or VBA code to update these values into a new format in a new table. for example the original data might be of race type:

1 - caucasian
2 - african american
3 - hispanic 1
4 - hispanic 2
5 - hispanic 3
6 - other

and i want to regroup these into less types, eg:

1 - caucasian
2 - african american
3 - hispanic
4 - other

how can i achieve this in Access? i know how i can do this conceptually with "if" and "case" statements, but I have no idea how i can do this in Access. I don't want to mess with the original data, so please help with CODE or QUERY examples.

thanks!!

View 4 Replies View Related

Reports :: Selecting Fields From Table For Query

Jan 13, 2014

I am looking for a way to generate a list of all fields within a table, have the end-user select which fields he/she wants to include, and then run the query. I am trying to create this within a form for a nice, easy to use GUI.

I am using Access 2010 on Windows. The fields I need them to select from are in one table, however there are many lookup (tblkp) tables related.

View 2 Replies View Related

Using Append Query - Update A Table By Replacing All Existing Information

Dec 6, 2013

Can I use the append query to update a table by replacing all existing information with updated information while at the same time adding all data that isn't currently in the table?

Right now every time I run the Append Query it just adds the same information as a new row instead of replacing the existing row with the updated information.

View 8 Replies View Related

Selecting Records Through A Form For A Query

Jul 13, 2006

I have a problem I should be able to solve, but I can't think my way around it.

I need to automate a series of tasks to perform the following:

1. The user clicks a button on a menu form and arrive at a select records form.
2. The user makes choices regarding the contents of certain fields (blank, not blank, equals a text string, etc.) and presses OK.
3. On the OK click, the fields are applied to a query, the results of which are exported in an excel spreadsheet.

I've been doing step 2 and 3 by hand in that I alter the selections in the design view of the query and save it. I then run a macro that deletes the data in the current table, runs the append query with the new criteria, and creates an excel spreadsheet of the new data.

However, I now have to make this functionality available to a non-tech person, thus the need to create a GUI menu that can launch a form on which the user can select options and with a single click, launch the macro.

I've tried adapting select forms that I've used with forms and reports using the doCmd.openquery, but they will only work for select or crosstabs, not appends. I considered having the form create the query and then qrite the append query off that, but I can't seem to get that to work.

Can anyone give me some direction on where I can take this?

Thanks.

Susan

View 1 Replies View Related

Forms - Adding Query As Data Source In Existing Form?

Dec 2, 2012

I am trying to add a query in an existing form. When I click on adding a field, I get an option to show "all tables" for not queries.

View 3 Replies View Related

Add New Field To Existing Table And Populate New Field With Existing Data

Apr 23, 2014

-Microsoft Access 2010

-Existing Access Database contains tables with 1-2 million records

I would like to add a field[dol] to an existing table[rei]. I need this new field[rei].[dol] to be populated with existing data from another table[main] based on the associated field[main].[account1] or [main].[account2] or [main].[account3].

Table1[main]
...account1
...account2
...account3
...dol

[code]...

In the [main] table. There is always data in [dol]. But there is NOT always data in the [account] fields. Sometimes there is multiple account numbers per [dol] but not always.

Customers will ALWAYS have at least 1 [account] number and [dol]. Some will have multiple [account] numbers and [dol]. Sometimes these [account] numbers are the same in multiple fields[account1] [account2] [account3].I just need to do a lookup or something to find the [account#] and pull in its [dol] from the [main] table and populate it in [rei].[dol].

View 14 Replies View Related

Filling A Table Using Combobox On A Form

Feb 26, 2005

I have a basic design question that I am not sure how to address.

I am trying to build a simple data entry database with a form to take input from the user, store the values in a table. Once the data is gathered into the table I want to use this table to print a report of each record (entered using the form before).

To achieve this objective, I made a form (frminput) with some text fields. Most of the fields on this form are Bound fields to a query (qrymaster). One of the field is a Combo box (whose value is shown from another table). I have designed the RecordSource of this Form to be a Query (qrymaster).

This is a basic Data Entry form where the user selects the Combo box item and based on what he selects, some of the fields in this Form gets pre-filled. The rest of the fields on this form are bound to the query "qrymaster" and the user has to type these fields manually.

Now, I want a Save button here that would save all the values on this form to the table "tblmaster". How do I do this efficiently keeping in mind all the normalization laws on the database?

At this time, behind the Save Button, I have included a SQL statement to insert all the field values into the table "tblmaster".

I am sure there is a better way to do this. Can someone point me in the right direction please?

Thanks.

View 3 Replies View Related

Using A Combobox On A Form To Select Table

Jan 23, 2014

I am trying to use one form to manage multiple unrelated tables that share the same field names (i.e. SKU, Name, Description) . My goal is to utilize a combobox or listbox to choose which table the data is sent to.

View 5 Replies View Related

Use Combobox From Form In Query

Mar 11, 2008

Hello,

I have a form containing a combobox with the values yes (1) and no (2).

In my query I have a date field. When the value of the combo is yes only the dates should be displayed. is the value no the the empty fields should be shown. I nothing is selected all fields should be displayed.

I tried this:


IIf(IsNull([Forms]![Form1]![cboDate]);
IIf([Forms]![Form1]![cboDate]=1;[tblITEM]![date_ID] is not null; is null);[tblITEM]![date_ID])

But without success.

View 1 Replies View Related

Selecting Data From A Combobox To Get More Data In A Listbox

Nov 21, 2005

im new to this so hello every1!!!

umm.. i have a form with a combo box which is linked to a table which gives me customer id numbers. and i have a listbox which i want the names and addresses to appear when i select a cusotmer id number from the combo box

so on the list box i put
" SELECT CustName FROM Customers WHERE CustID=$combo43; " in row source; if i change $combo43 to 0 the name appear but that is fixed and i want it 2 change when i select a cusomer id number from the combo box

can some1 plzz help me, its 4 my college project!

thanxs in advance!

purejoker!

View 1 Replies View Related

Forms :: Combobox In A Form To List Values Of A Field In A Table - Rowsource

Apr 14, 2014

So I have a combobox in a form that lists the values of a field in a table. The rowsource is this:

Code:
SELECT [Estes Training Modules].[Training Module], [Estes Training Modules].[Period] FROM [Estes Training Modules] ORDER BY [Period];

The problem is that ALL values on that field show up, including repeated values. I only need each different value to show up once. How can I do that?

For example, what I get in the combobox is: Annual, 2-Year, Annual, Annual, 2-Year, 3-Year,...

What I need is: Annual, 2-Year, 3-Year,...

View 10 Replies View Related

Using Combobox Name Selection In Login Form To Update Fields In LoginEvent Table

Apr 23, 2013

I have a login form with a combobox which derives its list of values from an EmployeeRecord table (i.e., last name, first name, securityID, job grade and record number): only the last name and first name appear in the list. (I swiped some VB code for a multiuser login form and routine from several previous posts.)

After it performs the security validation/authorization, it then opens a navigation control form based upon the user's job grade. It runs after the click button event. To this I would like to update another table, LoginEvent, with the last name, first name and record number from the combobox selection, and also add the time and date of the click.

View 2 Replies View Related

Show Current Record Value From Table In Combobox In Addition To Query Results

May 3, 2015

I have a table, with a related value in another table. E.g. A Items table with a batch value from another table.

I have a form to enter how many of these items has been used and from which batch number they belong.

The batch number is from a dropdown, and batches can be finished(exhausted) and marked such in the table so they no more show in the dropdown.

All this works fine, until, I go back to a entry which was from a batch that has been finished. The combobox is empty although the (Already finished) batch number is mentioned in the table. This is perfectly normal as my query for the combobox is :

Code:

SELECT ItemBatch.ItemId, ItemBatch.ItemBatchNumber, ItemBatch.Finished, ItemBatch.ItemName
FROM ItemBatch
WHERE (((ItemBatch.Finished)=False)
AND ((ItemBatch.ItemName)=[Forms]![ItemMasterForm]![ItemDataSheet].[Form]![ItemName]));

What I want is to show the current batch number as well. I tried to make this query get the current value, but wasn't successful. I tried to make a calculated field based on the dropdown and show its value.

Is there any way I can show the batch number in the datasheet? I have to use a datasheet and not a form, because there will be many sub records for the main form, and having a form will be very uneasy.

View 3 Replies View Related

Queries :: Dynamic Query Based On A Form (ComboBox)

Jan 22, 2014

We have a ComboBox on a form with the months: Jan, Feb, Mar, Apr, etc.

We have fields in a budget table named: Jan, Feb, Mar, Apr, etc.

We want to create a query that pulls the correct field based on the value in the combo box.

This is what I have that doesn't work:

MyField: [Query1].[SumOf] & Forms![Main Menu]![test]

How to do this?

View 4 Replies View Related







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