Modules & VBA :: Table Relationships And Select Statements

May 8, 2015

I have coded a select statement that uses multiple tables for information used to populate a report. It returns the correct information, sort of, but it doesn't recognize the already existing table relationships so I get dupicate records. Is there a way to run the code so that it recognizes the table relationships?

View Replies


ADVERTISEMENT

Select Statements

Mar 19, 2007

Hi,

I hope I posted this in the right forum. It didn't seem specific enough for the other ones.

I have a select statement in a form that reads as follows:


Select [Port of Origin] from [Port of Origin]

It works great. It does exactly what I want it to do.

I want to add another field to the statement but it is from a differnet table. If it was to stand alone it would read as follows:

Select [VendorName] from Container_Vendor_Information

How would I combine these two statements? I have tried various things can't get it to work. Any thoughts?

Thanks so much in advance.

Eddie.

View 2 Replies View Related

INSERT SELECT Statements

Mar 1, 2007

I was wondering if you can an INSERT SELECT statement for 2 tables w/ different data source?

Like one's from Oracle and the other's from Access?

Please help :D

View 4 Replies View Related

Nested Select Statements

Oct 4, 2007

SELECT tblNewTrans.Buyer, Count(tblNewTrans.Buyer) AS ["Total New Leads"], (select count(tblnewtrans.buyer) from tblnewtrans where tblnewtrans.new=true) AS Expr1, (select count(tblnewtrans.buyer) from tblnewtrans where tblnewtrans.refund=true) AS Expr2
FROM tblNewTrans
GROUP BY tblNewTrans.Buyer;


can anyone tell me why statement is working correctley. i have a table with a company field, paid field, refund field.

i need to run a query that gives me an amount to records for each company(that bit works), but also tell me how many payments have been recieve(new field) and how many payments have been refunded. all grouped under the correct company name. please help!!!!

the new and refund fields are checkboxes.

View 3 Replies View Related

Nested Select Statements

Oct 30, 2007

I am trying to combine the below queries into one using nested Select statements, but I am not having any luck. Any examples on how to do this would be appreciated. Thanks



qry1000_006_01-Base4 syntax:

SELECT RIVMTRM0_STDY_GRP_TST_REMARK.IVMSGRP, RIVMTRM0_STDY_GRP_TST_REMARK.IVMTESTSN
FROM RIVMTRM0_STDY_GRP_TST_REMARK
GROUP BY RIVMTRM0_STDY_GRP_TST_REMARK.IVMSGRP, RIVMTRM0_STDY_GRP_TST_REMARK.IVMTESTSN
HAVING (((Count([IVMSGRP])<>Max([IVMRMKSN]))=-1));


SELECT [qry1000_006_01-Base4].IVMSGRP, [qry1000_006_01-Base4].IVMTESTSN, RIVMTRM0
_STDY_GRP_TST_REMARK.IVMRMKSN, RIVMTRM0_STDY_GRP_TST_REMARK.IVMRMK
FROM [qry1000_006_01-Base4] INNER JOIN RIVMTRM0_STDY_GRP_TST_REMARK ON ([qry1000_006_01-Base4].IVMSGRP =
RIVMTRM0_STDY_GRP_TST_REMARK.IVMSGRP) AND ([qry1000_006_01-Base4].IVMTESTSN = RIVMTRM0
_STDY_GRP_TST_REMARK.IVMTESTSN);

View 1 Replies View Related

Modules & VBA :: Create Sequence From Table Of Relationships

Jan 14, 2015

I am writing a deposit recording database for archaeological layers. My units are recorded in one table, and then the relationships are recorded in a separate table. I have limited the recording of relationships to be either "same_as" or "below".

So in tblContexts is have say: 1,2,3,4,5,6

In tblcontextrels I have say : 2 is below 1; 3 is below 1; 4 is below 3; 1 is below 5; 6 is the same as 5

I want to view the deposits on screen in their stratigraphic sequence. So I think I need to write a piece of code to run through "tblContextrels" which will then create a hierarchy attribute. This attribute can then be used to sequence the context deposits I am looking at.

View 12 Replies View Related

Modules & VBA :: Table Relationships And Nested Forms - Copy Sub Form Records

Aug 3, 2015

I've attached screenshots of the table relationships and some nested forms that I need to discuss in my database.

If you look at the forms screenshot you'll see I have a main form "business/cmc issues" that uses a combo box to select a business name; nested into that I have a second form "policy issues log" that holds details of policy issues about that business; then inside that I have a sub form "issue updates" that records brief details about the actions carried out in trying to resolve each policy issue.

The same policy issue can affect more than one business (because of a relationship between the two companies etc) but still needs to be viewed separately. So for example in the business selector combo box I might have business "ABC". In the policy issue it might say "doesn't pay on time". The "doesn't pay on time" issue might also apply to business "123" and so if I picked that business from the combo box you'd see the same policy issue.

Because it's the same issue for two separate businesses, the actions carried out will be the same, so what I want to do is, after a new action is carried out (where relevant) to be able to click a button that would run some code that copies the actions entered in the sub form for business ABC and pastes them into the sub form for business 123 where the product area and policy issue are equal. This is to avoid having to enter the same data twice.

View 3 Replies View Related

Modules & VBA :: Drop Down Select From Another Table

Jul 7, 2015

I had 3 drop down filters that worked when the word being filtered was written in the table. I have since then linked them to new tables to be more database-y. The problem I have found (a couple weeks later too) is that my drop downs broke.

It makes sense why, they are now 1,2,3,4 instead of words but how do I make this work now that it isn't in the current table?

Code:
Private Sub cboMDS_AfterUpdate()
Dim myPlane As String
If Me.cboMDS = 0 Then
myPlane = "Select * from Baseline"

[Code] ....

View 10 Replies View Related

Modules & VBA :: Using If And Case Statements

Dec 16, 2013

Basically I want to check if the Reporting Month already exists in the Months Table. If it exists it should ask the User wheter to overwrite or not. If the User clicks on OK it should delete one record from Months Table if the User clicks no, nothing should happen.However it doesn't delete the record, when I click on OK.

Code:

Public Sub IMPORT_Click()
Dim filelocation As Variant
Dim f As Object
Dim Message As String, Title As String, Default As String
Dim sql As String
Dim MsgReply As Integer

[code]....

View 1 Replies View Related

Modules & VBA :: Report With Only Select Records In Table?

Dec 17, 2014

I have a master table located on the backend of the server with about 3 fields:

Software
Version
Description

I have 4 databases, one for each software on the front end accessing this master table.

So far I have in the master table a dropdown to select 1 of the 4 software's, the version number and a brief description.

One the front end I have a button that when pressed will bring up the report based on the master table.

Can I have the report just select the software that it refers to. For instance if the datebase is Sony when I click on the report it only grabs the records with Sony on it. For my next database when I open up Sharp's database it only makes a report for the Sharp records.

How would I do this? Is this something I have to code or something I can do in criteria or do I create a query?

View 2 Replies View Related

Modules & VBA :: Viewing Output Of SQL Statements

Feb 27, 2015

The following SQL statements run with no errors, but I can't see the output of the SQL statements. What is wrong with my "Debug.Print" or "rs" statement ? I would like to see the results. The SQL statements works when I save them to a query.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Rem Dim intResult As Integer
Dim strSQL As String
Set db = CurrentDb

[Code] ....

View 4 Replies View Related

Modules & VBA :: Using Parameterized Values In SQL Statements

Oct 15, 2013

I've seen a common solution is to double up the apostrophe, replacing ' with " to avoid the special character however i also hear of another solution using "parameters".I tried have a look around on the internet and got confused so I thought maybe it would be better to ask here.

I just want to change my INSERT INTO and UPDATE commands to be able to use this (to prevent a potential sql injection) also i think its important to know im using DOA to code? (not sure if its important) either way.

View 3 Replies View Related

Modules & VBA :: Multiple If Statements Into One Procedure

Jun 26, 2013

I'm trying to put multiple IF statements into one procedure like the below:

Dim Answer As Integer
Answer = MsgBox("Have You Selected The Correct Outcome?", vbCritical + vbYesNo, "Continue Request?")
If Answer = vbYes Then 'Works fine here
'The bit I can't get right

[Code] .....

View 2 Replies View Related

Modules & VBA :: Edit Conditional Statements Via Form

Aug 31, 2013

I have a table of marks of student, a query that calculates totals and a form that displays results. on the query, i have an if statement.

Code:
comment:IIf([Marks]>=80,"good",IIf([Marks]>=50,"fair",IIf([Marks]>=40,"Work harder")))

So i want to be able to make the whole syntax available for user to edit without actually doing it in vba. is this possible in vba? i have attached an image

View 8 Replies View Related

Modules & VBA :: Combine OR Statements In Junction With AND Statement

Aug 20, 2013

How do I combined multiple OR statements in conjunction with an AND statement as follows:

If [Len(Field1 & "")=0 OR Len(Field2 & "")=0] AND Field 3 = "Something" AND Field 4 = "Something" Then...

I thought there I had to use a | symbol but I am not exactly sure?

View 2 Replies View Related

Modules & VBA :: Easy Way To Write Nested IF THEN ELSE IF Statements

Apr 12, 2015

How do you write complex nested IF THEN ELSE END IF statements..How do you know what IF statement to put first?Then how would you know where to put ELSE, or END IF?Before you start with the VBA, what are the foundations for making it work successfully, know where you are, know where to put END IF etc?

I've seen many times when using VBA people set up an initial foundation for writing code. For example when needing to put something in quotes, they do "" then enter the text in between, so they don't get errors on running (A very simple, crude example I know, but is there a similar basis for nested IFs).

View 6 Replies View Related

Modules & VBA :: Write Select Query That Will Search The Data From Bottom To Top Of Table

Dec 3, 2013

see below the code . The select statement searches the Printpoolno value from the top to bottom in table tblmaster. As in my table tblmaster there are thousands of records and it takes long to search for that Printpoolno from the table . Is there anyway we can write a query that will search the table from bottom to top as the Printpoolno will always be in the bottom records and not in the top records.

Code:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim r As Long

[Code].....

View 3 Replies View Related

Modules & VBA :: Allow User To Select Record From Subform And Add It To Table - Insert Statement

Jun 18, 2013

I have a sub form with staff records on it within a main form. I am trying to allow the user to select a record from the sub form and add it to a table, here is my code which, to me, looks correct. However it gives me an error saying "Syntax error in INSERT INTO"

Code:
Private Sub Command3_Click()
Dim dbs As Database
Dim sqlstr As String
Set dbs = CurrentDb
Forename = Nz(Forms!frm_Capex_Submission!frm_staffSub.Form.shy_forename, "")
Surname = Nz(Forms!frm_Capex_Submission!frm_staffSub.Form.shy_surname, "")

[Code] ....

View 1 Replies View Related

Modules & VBA :: Using String To Update Records - Quotes And Apostrophes In SQL Statements

Dec 4, 2014

I'm having problems with quotation marks in a sql statement. The string is an array separated by a semicolon.

120/80;70;5'6";125

this string represents patient vitals. I'm using the string to update a record. But I get hung up with the quotation mark.

I've tried: 120/80;70;5''6'"';125 which is a enclosing the quotation mark with apostrophies, but this does not seem to work. The sql still gets hung up. My sql statment looks something like:

original string: 120/80;70;5'6";125

strPreOpVits = "120/80;70;5''6'"';125"

mysql = "UPDATE mytable SET PreOpVits = '" & strPreOpVits & "' " & _
"WHERE nID = " & myRecID

docmd.runsql mysql

I've narrowed it down to the quotation marks and I'm unsure how to handle these. I get a runtime 3075 - Syntax Error.

Here is the code that I use to convert the original string

Public Function FixQuotesInSql(strToFix As String)
Dim lgth, y As Long
Dim strTemp, char2Add As Variant
'This routine fixes the use of apostrophe and quotation marks in an SQL sequence
'If the apostrophe is at the beginning or end of the string it replaces with 3 x "'" or "'''"
'If in the middle of the string then replaces with 2 x "'" or "''"

[Code] ....

View 7 Replies View Related

Modules & VBA :: Programmatically Find And Select Item In Multi Select List Box

Apr 23, 2015

I have a multi slect list box (simple) and I need to find and select an item using vba - e.g., the bound column is the ID field and I need to select a specific ID (which will be different each time) as opposed to selecting the 100th record for example. How do I do this?

View 2 Replies View Related

ALTER TABLE And SEPARATE DATA SQL STATEMENTS

Jun 7, 2005

Helo…please really need your help.

I designed a small desktop database to automatically import some Log files. A sample of a transmit log file (emails sent from our rural email stations) looks like this when imported in access.

Date Time Direction SenderMessageID
03062005 133501To InternetemailX@ab.comBlablabla
03062005 125001To InternetemailQ@ab.comBlablabla
03062005 125001To InternetemailZ@ab.comBlablabla
03062005 125001To InternetemailA@ab.comBlablabla

I would like to be able to query all emails sent between one date and another. However, the date here is recorded has a string or text. I would like to automatically add a field with the date as Date/Time datatype in the Table. I think I should be able to do this with a few SQL statement like ALTER TABLE myTable ADD COLUMN NewDate AS datetime…and then another SQL statement to separate data and put it into this new field.

Then I could query for BETWEEN Date1 and Date 2 easily.

I’m pretty close but been trying for a while now and always error messages as results. I think I really NEED help this time.

Thank you,

Ghislain Bob Hachey

View 5 Replies View Related

Forms :: Linked Table - IIF Statements In SubForms

May 15, 2013

I have some linked tables I'm using as subforms. I'd like to make the data a little more readable rather than numbers that my linked table spits out (can't do anything about it).

In my main form I can use the control source and enter something like this:
=IIf([FieldName]="1","Male",IIf([FieldName]="2","Female"))

I can put as many statements as I want, just add a bracket at the ned for each one. Works great.

This however does not work in the subform. I get a circular logic error. If I then add a table reference like:
=IIf([TableName]![FieldName]="1","Male",IIf([FieldName]="2","Female"))

The error goes away, but it still displays as #Name?

View 3 Replies View Related

Queries :: IIF Conditional Statements To Assign New Values In Table

Apr 11, 2013

I am writing some iif conditional statements in one of my tables to assign new values in that table.

Code:
FP: IIf([cohort with status].[Intake Date] Between #04/01/2012# And #26/04/2012#,201201) Or IIf([cohort with status].[Intake Date] Between #27/04/2012# And #24/05/2012#,201202)

When I run it, I am getting some -1 values in the new column FP.

but if I get rid of the second IIF, then it works.

how do you combine multiple IIF statements in a query?

View 1 Replies View Related

Modules & VBA :: Getting Error End Select Without Select Case?

Sep 5, 2014

When I run the below code I am getting the error "End Select without Select Case" I figured it might be because I have the "End Select" before the "End With" however when I move the "End Select" after the "End With" I get the error "Loop Without Do".

Code:
Private Sub cmd_Update_Conditional_Codes_Click()
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset

[Code].....

View 3 Replies View Related

Modules & VBA :: Creating Temporary Relationships Between Tables

May 3, 2015

I'm thinking about creating temporary (while db open) relationships between tables, since transfering tables is possible only if no linked relationships are present. However it's important to preserve in some cases referential integrity.Looking online, I found this code:

Code:
Public Function CreateRelation(primaryTableName As String, _
primaryFieldName As String, foreignTableName As String, _
foreignFieldName As String) As Boolean

[code]...

Even with the comments I don't really understand what exactly this code does or doesn't do.I tried the code. It seems (?) to create a relationship. Since the relationship doesn't show up in the relationships table, I'm not really sure if it's there.

- why it's not visible among other relashionships (or is it me?? maybe, it wasn't the code that was working but the query...)
- how to implement referential integrity
- what's the behaviour of this supposed relationship. Is it permanent or not? If not when is it deleted?

View 12 Replies View Related

Table Relationships

Oct 14, 2005

I am trying to put together a sales/purchase/stock control/accounting program using Access. I have put together a number of tables that I feel will be required and now I'm trying to set the relationships between them. The primary end document to be printed will be a Sales Order and a Purchase Order, likely generated from the reports module, so I have a table called Purchase Order and another called Sales Orders, related to Purchase Orders will be a table called Suppliers and another called Customers will be related to Sales Orders. Another table is called products.
For the Purchase Orders table, do I only add fields that are the primary key from the Suppliers table in order to list the full customer name and address stored only in Suppliers table. Would the supplier table be the parent and the Purchase Order the child ?

View 3 Replies View Related







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