Modules & VBA :: Selecting Records For A Recordset Using Datediff?

Apr 14, 2014

I have a table with Family_Name and Birthdate and tblxx_Familie_ID:

I am trying to create a recordset that selects all records that belong to a certaim Family and where the Person is under 216 months old (under 18)

Set ExternKinder = db.OpenRecordset("Select * from tbl_ExterneGeschwister where tblxx_familie_id=" & Familie!ID & " and " & "Datediff('m',[Geboren_am],[me![Buchungsdatum]) <= 216)

'Buchungsdatum is a filed on a form that I start the procedure from...

View Replies


ADVERTISEMENT

Modules & VBA :: Randomly Selecting Records Within A Filter

Jul 30, 2013

I have a scenario that I tried on an Excel forum but didn't have much luck. Conditions for my assignment:

1) Long description short, I have to randomly select 2 records for each client each month.

2) The catch is that these records have to be different states until the process is done for all 50 states, so the process isn't done for 4 years and 2 months (50 months).

I attached a sample database.

View 3 Replies View Related

Modules & VBA :: Loop Through A Recordset While Adding New Records To Another?

Jun 9, 2014

Is there a way of looping through a form record set, while adding new records to a different form record set? using some data from the 1st record set in the new records?

View 8 Replies View Related

Modules & VBA :: How To Loop Through Recordset And Only Attach Records That Are True

Jul 8, 2015

I have some code that loops the clone recordset of my subform and generates a email with attachments. I have mainform and continuous subform within the subform I have field called address this holds paths to files and another field called send and this is a yes/no field

Now what I'm trying to do is loop through the subform if send field is true then attach file from the address path but if send field is false then do not attach file

Code:
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim olAttach As Outlook.Attachment
Dim rstAttach As DAO.Recordset

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

[Code] ....

View 14 Replies View Related

Modules & VBA :: How To Extract Recordset From Subform Into Recordset Object

Aug 14, 2015

Special situation: The SQL Server Linked Server across the country is linked to a Read Only Oracle DB. This data pull works perfectly and populates the Subform.

The problem is that Oracle can take 3 to 6 seconds to retrieve the single record depending on the network traffic through a small pipe.

The code below shows the RecordSource for the SubForm. clicking on a list box supplies the value. Then 3 to 6 seconds later, the subform populates.

The actual Recordset for this Recordsource is needed to conduct Validation on each field. Normally this would be on SQL Server, I might just create a Recordset Oject and run this SQL statement again in 1 milisecond. In this case, it will probably take an additional 3 to 6 seconds. Avoiding another lengthy round-trip to Oracle would be prefered.

Goal: How does one grab, clone, or other wise reference the existing recordset for the SubForm?

Note: Immediate Window - One single field can be returned quickly

There are 48 fields that need validation - is there a way to reference the entire recordset?

Immediate Window during Break Mode:
? me.fsubsrNavSHLBHL("NavSH_QQ")
NESE ' this is the correct value for the current recordsource

Set a breakpoint right after the line:
fsubsrNavSHLBHL.Form.RecordSource = "Select * from vsrNavigatorSHLBHL where Well_ID =" & txtNavWellID.Value

Immediate Window:
? me.fsubsrNavSHLBHL.Form.RecordSource
Select * from vsrNavigatorSHLBHL where Well_ID =91229

View 4 Replies View Related

Modules & VBA :: Can Use Result Of One Recordset For Other Recordset

Jul 7, 2013

I want to write a email where there are 2 or 3 different ordernumbers for same email, i want to include the email in the mail part as single column table. how to do it? also can i use result of one recordset for other recordset?

View 1 Replies View Related

Selecting First 10 Records

Apr 10, 2006

Hi,

I have a query that gives an out put of 'worst offenders'. these offenders are in order of on field ascending (number of entries made per week) and another field descending (total sales).
It is by the combination of the sorting of these fields that we have an ordered list of offenders.

For my report i want to only see the top 10 records of this sorted list.

so for this selection i simply want to select the [B]first 10 records [B]of the ordered list. I cant make a selection by any one particular field(as explained above)

i have looked into the 'select top' functions and 'dfirst', but I dont think they'll work for me.

Any ideas?
Slighlty confused,
Rosxx

View 3 Replies View Related

Selecting Records

Jun 11, 2007

hey guys, im having one last problem with a report im making. just want to thank boblarson, Rich and Dennisk for all the help they have given me upto now, i have added to your reputation guys, thanks!

My problem is as follows:

I have a form for my products and a subform for the suppliers, each product can have many suppliers.

I need to have a report of products to send out to customers, so i created a check box to "tick" if i want to include it in the report. So far so good, however, the report shows each product several times for each supplier :(

can anyone tell me how to select only the supplier with the lowest supplier price for each product

Cheers guys

View 9 Replies View Related

Selecting Top X Records

Jul 30, 2006

Hope someone can help.

I am building a database to evaluate football team performance. I have a table with results (tblResults) where a team will have records in either the Home Team or Away Team fields depending on the fixture.

I want to include a "Team Form" calculation that selects the last 6 games for each team (both home & away) and allocates points to calculate a recent form stat for comparison with the opposition.

I have tried using the TOP VALUES option in a query, but I can't seem to get it to extract the top 6 in descending date order for every team.

Would be very grateful if someone could help!

View 3 Replies View Related

Selecting Records By Date

May 18, 2007

I created a personal database for keeping track of my meeting schedules. My table has Date field, Time field and Subject field. I have made several entries. On a given day, I have several meetings at different times.

I created a combo box in my form to choose the Date and see that day’s meetings. The meetings list of the date chosen by combo box should appear in my form. But here I think I made a mistake. Each record has date, time and subject. When I click the combo box, the drop down list shows the same date many times (as I have entered the same date but different time and subject for each record). How do I make the combo box display the date only once and not same date several times? Do I have to change the table set up? Please guide me.

View 1 Replies View Related

Selecting Specified Number Of Records

May 19, 2005

I have a database that allows the user to order clothing items.
Each size of each item has a different stock number.

I have [StockNo] - [StaffNo] - [Qty] i need to generate [OrderNo].

The problem i have is that [OrderNo] is incremented after every five five items (ie[StockNo]).
This gives me my first problem of selecting just the first five records of a table in order to allocate an order number.

The second problem i have is that in order to allocate an order number, i have to summarise the [Qty] by [StockNo].
This gives me the opportunity to select the order number but i lose the individual [StaffNo] information.
This information, together with the [OrderNo] is needed for a master order table.

I have created a crosstab query which summarised the [StockNo]but how do i retrieve the [StaffNo] information from the column headings.

I am new to Access and would be grateful for any help or comments as to whether i am going about solving this problem in the best way.

Thanks

View 1 Replies View Related

Selecting Records Using Combo Box

Feb 16, 2005

Hi,

ok part of my database is made of 2 tables.

tblItems
item_id
maunfacturer_id
supplier_id
item_name

tblQuantities
quantity_id_num
item_id
quantity

(item_id linked)


ok so I want a form that has a combo box with [item_id, item_name] on each row that i select. when i select one it displays the relevant quantity and allows me to edit the quantity.

any ideas how i can do this?

Thanks:)

View 3 Replies View Related

Searching And Selecting Records

Sep 5, 2004

I'm trying to write an app that will allow the user to search for records based on database fields, then select a subset of those records to be manipulated by other functions. The VBA book I'm reading led me to believe that a RecordSet would be the best way to store this subset of records, but searching around on the web has pointed me toward using a DAO.QueryDef. I can't seem to get either method to work!

Here's a quick overview of the app: everything is placed on one form. I have two tab controls that make a sort of upper and lower set of pages. One of the lower pages has the search functions. The user enters his search criteria into one or more textboxes (correlating to database fields, i.e. Last Name, SSN, etc), then hits the Search button. This should query the database, then populate a listbox with the search results. The user can then select one or more records from the listbox, hit another button, and the selected records are copied to another listbox on a page on the upper half of the form, where they can be further manipulated.

Can someone advise me on the best objects to use to accomplish this? A short code sample would be awesome.

By the way, does VBA have some sort of online API reference (like Java)? I know that MS Access has the object browser, but it doesn't give descriptions of the objects, nor does it list methods that can be invoked on them. Could someone also point me towards some good programmer's resources?

Thanks...

View 2 Replies View Related

Selecting Records From Unbound Box

Jul 30, 2012

I am using an unbound box on the top of a form where I would like to select a clients name and have the form populate with their info. My problem is that the box will pull up the record by last name, but only pull up the first record with that last name in alphabetical order.

Example, If I have the following names in my database

Ben Smith
John Smith
Tim Smith

If I select "john smith" from the drop down "ben smith" will show up, if I select "tim smith" "ben smith" will still show up. If I select "ben smith" the correct record would show up.

An image of the property sheet is attached ....

View 6 Replies View Related

Selecting Records Greater Than Seven Days Old

Feb 28, 2006

I tried the Crystal Reports forum, but no responses. Can anyone see what I'm doing wrong with the below statement in Crystal Reports 8.5. I'm
trying to select reecords that exceed 7 days based on a Crystal Reports parameter. The parameter has the format of 2/27/2006 (Discrete value). The 'LastRouteDate' has a format of 'datetime'. Thanks ! ! !


{?Select_Date} - DateValue({Applications.LastRouteDate}) > 7

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

Selecting Equal Amount Of Records

Jul 12, 2007

I was wondering if someone could help me.
I have a simple table with data that gets updated daily. I need to split the data into 5 equal parts for work distribution. Because the amount of records always changes I can not go by numbering so I need to go by percentage, to split it into 5 ( 20% ) parts. Please help.

View 5 Replies View Related

Selecting Records With A Prompt For Date

Nov 29, 2007

I have looked but have been unable to find the answer in past posts and this must be a common problem. I wish to include all records up to and including a date passed in the prompt "Criteria: <=[enter end date]". I changes the date format in the back end to short and I am in the US. However I get only dates less then the the prompted date.
Thanks for any help
Jim

View 10 Replies View Related

Selecting 4 Records At Random From A Table

Apr 2, 2006

Hi All,

Any ideas on how I do the following.

I have a table with 1500 records in it.

I want to select at random 4 of these records and append them into another table along with some other data that the query will not pick up, in this case Pilot and Month.

I guess I am having to go the VBA route but dont have a clue on how to do it.

Cheers in anticipation.

Andy.

INSERT INTO Assignments ( flightcode, aircraft, depart, destin, pilotcode, [Month] )
SELECT Schedule.Flightcode, Schedule.Aircraft, Schedule.Departure, Schedule.Destination, [pilot] AS Expr1, [MONTH] AS Expr2
FROM Schedule
WHERE (((Schedule.Departure) Like "man*"));

View 3 Replies View Related

Selecting Multiple Records From A Combo Box?

Jun 15, 2006

Is it possible to have a combo box on a form and allow users to select multiple entries from the drop-down list? Thats just the tip of the iceburg. If you can, then I'll probably be asking more questions soon.

Thanks in advance.

View 2 Replies View Related

Selecting Week Of Records From This Weeks Date

Jun 27, 2005

Hi,

I am trying, and getting nowhere...so would appreciate your help... to create a query where records with dates from 8 weeks, or two months ahead appear in the query.

That is I have contracts ending in two months in my table and I want to run a query on who I should call now to renew contracts.

I have a contract end date in table.

I have tried
>=DateAdd("m",2,Now())<=DateAdd("m",2,Now())
only to get all sorts?

>=DateAdd("d",60,Now())<=DateAdd("d",68,Now())
only to get all sorts of things appearing?

Anyone that could help would be great.
I have contact info in a TBLCONTACTS and linked to TBLMOBILES via COMPANY_ID

Thanks heaps!

C

View 2 Replies View Related

Selecting Records Based On Multiple Criteria

Jul 10, 2007

hi,

i am querying a single table that contains card numbers and corresponding transaction codes (amongst other things). a single card number can have multiple transaction codes.

i want to select all card numbers that have both 0100 and 0802 transaction codes.

if i use a select query with ="0100" Or "0802"as the criteria, it returns all card numbers that have either 0100 or 0802 transaction types. if i then change the query to crosstab and group by card number, it is clear that some cards have both transaction types.

when i try to change the criteria to ="0100" And "0802" it returns nothing at all.

i'm sure the solution is something really simple - any idea what i'm doing wrong?

View 7 Replies View Related

Selecting Certain Records To Display In An Unbound Combo Box

Sep 15, 2005

Ok sorry to be a pain :D

I have a main form frmProperty from where you can go via a button to frmTraining and these two are linked by "Property Code".

On frmTraining i have an unbound combobox which gets it data from the tblTraining table. I want this to only display data for the "Property Code" that the frmProperty is pointing to.

I assumed this would just work if the link criteria was present in the button code, however it appears that no matter what the "Property Code" the combo box displays all the data in the tblTraining table.

Anybody have any ideas?

Many thanks

View 1 Replies View Related

Searching And Selecting Records To Be Appended To Table

Dec 6, 2004

Hi,

I have a form that runs a parameter query to search for university name and then displays 2 fields, university name and course name.

I am having difficulty with a search button that i have on the form called search_command; it is supposed to run the exact query as when you enter the form, it does this but displays the result in a dataheet, i want it to repopulate my 2 text label fields as mentioned above.

In addition i want then to be able to go to a specific record, select it and then press a button to append it to another table. i ahve not started this part yet

Can anyone please help ?

View 14 Replies View Related

RecordSet Doesn't Get All The Records...

Feb 9, 2005

On one of my Access2000 forms, I have the following sub that takes the user to a particular record whose value is passed to the sub as a variable. It frequently results in EOF being true because the recordset does NOT get all the records in it during rs=RecordsetClone. I set a msgbox to tell me the RecordCount, and even though there are almost 3000 records in the underlying table, the rs.RecordCount was anywhere between 300-750 each time I ran the code. Therefore, rs.find won't find the right record most of the time, because that record won't be in the recordset. What causes this and how can I fix it?

Here's the code -- I've got MoveLast and MoveFirst both in there to help ensure that all the records get grabbed, but that had no effect; I still get EOF:

*****************************
Public Sub GotoOrder(pOrdID As Long)
On Error GoTo Err_GotoOrder

Dim rs As ADODB.Recordset
Set rs = Me.RecordsetClone

rs.MoveLast
rs.MoveFirst
rs.Find "OrderID = " & pOrdID

If rs.EOF Then
MsgBox "Record not found."
Else
Me.Bookmark = rs.Bookmark
Me.Visible = True
Me.SetFocus
End If
Exit_GotoOrder:
Exit Sub

Err_GotoOrder:
MsgBox Err.Description
Resume Exit_GotoOrder

End Sub

View 3 Replies View Related

Help Required Selecting Specific Records From Related Tables

Apr 15, 2008

Hi,

Hope someone can help me out on this one. Searched the forum but can’t find anything to help me out.

I have two tables:
tblCustomers that contains unique customer records (names addresses etc.)
and
tblComments that contains comment data for the customers

Tables are joined one to many tblCustomers -> tblComments on account_ref

tblComments can contain several records per customer, all are datestamped.

I want just the latest datestamped comment record per customer, just can’t seem to work the logic on this one. Must be so simple but can’t fathom it.:confused:

Ideally, I’m producing a report of Customer data (Name, address, contacts etc) + the last comment record for each customer. Have started with a simple query, but have hit an impasse. Have tried sorting, group by, top 1, distinct etc, but don’t seem to be getting anywhere.:mad:

If someone can point me in the right direction, and give me a starter for 10 I’d be much appreciated.

View 1 Replies View Related







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