Modules & VBA :: Exporting Subtable Records With Primary Records
Jan 12, 2014
All seemed to be working well, however, I noticed that all my subtable records in the database are exporting with each Primary table record. In my output, I'm looking to see each primary table record followed by one or more subtable records from a one to many relationship.
(Office 2010) Access/Word
Private Sub cmdPrint1_Click()
Dim objWord As Word.Application
Dim docm As Word.Document
Dim db As DAO.Database
Dim rstLandSales As DAO.Recordset
[Code] ......
View Replies
ADVERTISEMENT
Oct 26, 2004
I have a table, and there are many records, each with a unique value in the OrderNumber field
I have a text box on a form, and i want it to work so that the user types in a OrderNumber value, and it loads that record into the form (the form is bound to the table)
I already know how to load a record by record number, but how can i do it by OrderNumber value?
thanks
View 2 Replies
View Related
Jun 5, 2015
I recently acquired a database that is already established. When entering new date the primary key is null. I've looked at the properties and the best I can figure is it has something to do with a missing property called New Values.
View 12 Replies
View Related
Aug 2, 2005
I have been trying to figure out how to do this and the transferdatabase function wouldn't do what I needed. I have a table that has a bunch of records, each being a request for cad work somebody wants me to do. I change the status of each one to pending, working, or complete. Anyway I want to only keep the completed task records in the database for 90 days. After that the records will be exported to an archive database and purged from the working database. The problem I face is not getting the records I need “I used date stamps ;)” but getting the records I filtered to append the archive database table and not overwrite it. I made backups ;) of my db and am testing on those and cant figure this out. Below is the code I used to export. Like I said it overides the table rather than append...
DoCmd.TransferDatabase acExport, "Microsoft Access", _
"X:Archive.mdb", acTable, "tRequest", _
"tRequest"
MsgBox "its done"
Any ideas, pointers, stern words and a link to a post I missed, anything to help is appreciated. :o
Thanks,
Eric
View 1 Replies
View Related
Jan 12, 2015
I have stored data in access. The records have name, address and unique Id. I want to be able to extract the unique ID from the Access database for all those records that match the name and address in any new file that I compare my Database with.
View 10 Replies
View Related
Jun 15, 2013
In an Access 2010 form is it possible to export select records and fields in those records to a specific location?
Code:
Set objDialog = Application.FileDialog(4)
With objDialog
.AllowMultiSelect = False
.Title = "Please select a File"
.InitialFilename = "C:"
.Show
If .SelectedItems.Count = 0 Then
MsgBox ("Action Cancelled")
Else
[code]....
The user can select the directory using the code above, but can specific fields in records be exported to a excel workbook in that selected directory?For example, if the are 5 records in the database can the fields LastName,FirstName,BirthDate in records 1,2,3 be exported to Setup.xlsx in that selected directory?
View 1 Replies
View Related
Sep 21, 2015
I have a modest sized data base and have been having trouble keeping out duplicate records with the same last name, first name, and DOB. I know I could use all 3 fields as a primary key, but I would like a simpler way of checking for duplicates.
View 3 Replies
View Related
Feb 7, 2014
I have a table InvPrice and Updated Pricing
Need to delete all records from InvPrice that Match UpdatedPricing
InvPrice.StockCode = UpdatedPricing.StockCode
InvPrice.PriceCode = UpdatedPricing.StockCode
I have tried something like this...
Dim dbs As DAO.Database, sql As String, rCount As Integer
Set dbs = CurrentDb
sql = "DELETE * dbo_InvPrice Inner Join (dbo_InvPrice Inner Join UpdatedPricing on dbo_InvPrice.StockCode = UpdatedPricing.StockCode ) ON on dbo_INvPrice.PriceCode = UpdatedPricing.PriceCode "
dbs.Execute sql, dbFailOnError
View 14 Replies
View Related
Dec 3, 2014
I have a table which has a primary ID and then date/time then an empid field relating to an empid table,
Is it possible to design a query to return all records per empid which exceed 30 minutes for the last 30 days? or even 'today' or a specified date whichever is easiest?
View 6 Replies
View Related
Aug 6, 2005
OK, I've tried everything I can think of with this query/subform/records problem. I've searched the internet for days, even bought some big fat Access reference books and read them cover-to-cover, but I still can't get my database to do what I want. This newbie would *really* appreciate some help...
I am trying to create a database which I can use to store client’s advertising expenses. I currently have three tables: tblListings (which stores basic information about each client, with the field ListingID as the primary key); Advertising Rates (which stores the different types of advertising products and their prices, with the field ProductNumber as the primary key); and tblAdvertisingExpenses (which stores each “order” of an advertising product, including the client’s ListingID as a foreign key, date, the type of advertising, and the total cost - the primary key is an auto-numbered field called OrderNumber).
I have a main form called frmListings, which displays the client’s information from the tblListings table, and includes a subform. I wanted the subform to show only the advertising expenses corresponding to the ListingID (ie. client) displayed on the main form, so I based the subform on a query which displays all records from tblAdvertisingExpenses with a ListingID that matches the ListingID displayed from tblListings. So far so good - the records displayed in the subform change correctly when the record in the main form changes.
Now the tricky part…
The subform displays a blank row for a new record, and I would like to be able to enter a new advertising expense in that blank record (date, type of ad, and cost), and have that data added as a new record in the tblAdvertisingExpenses table with a new auto-numbered OrderNumber. I don’t know whether it’s because the subform is actually a dynaset from a query, or because I’ve constructed the query incorrectly (highly likely, I’m still pretty new to queries), but when I add in the details for the new record, I get the following error:
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship (etc, etc).
I suspect that Access is attempting to write the record (along with the ListingID) back to the tblListings table, where the same ListingID already exists (uniquely) as the primary key. But I don’t know for sure, because I don’t really know what the heck I’m doing. What I actually want to do is have the new record I’ve entered in the subform added to the tblAdvertisingExpenses table, which is the record source for the qryListings query which displays records in the subform. It shouldn’t be a problem, should it? So why can’t I get it to work? Perhaps there’s a fundamental flaw in the way I’ve broken up the database into tables, or my assigning of primary keys and foreign keys. Or perhaps there’s a flaw with the way I’ve constructed my query. Or am I forced to have a completely separate form solely for entering data into the tblAdvertisingExpenses table? Or will I need to use a macro or VBA to accomplish what I want?...
Sorry if this is terribly confusing. I can provide more specific details (and screen captures) of the tables, queries, forms, and relationships (if I haven’t provided enough specific details already), and would really appreciate any help that anyone can provide. Help?!
View 3 Replies
View Related
Jun 17, 2013
I have a calculated field in a query. The field name is TotatPt (this is to calculate the total points students have earned during the term). The expression is as follows:
Code:
TotalPt: [Att1Pt]+[Att2Pt]+[Att3Pt]+[Att4Pt]+[Att5Pt]+[Att6Pt]+[Att7Pt]+[Att8Pt]+[Att9Pt]+[Att10Pt]+[Att11Pt]+[Att12Pt]+[Att13Pt]+[Att14Pt]+[Att15Pt]+[Att16Pt]+[Att17Pt]+[Att18Pt]+[Att19Pt]+[Att20Pt]+[Att21Pt]+[Quiz1Pt]+[Quiz2Pt]+[Quiz3Pt]+[Quiz4Pt]+[Quiz5Pt]+[Quiz6Pt]+[Quiz7Pt]+[Quiz8Pt]+[Quiz9Pt]+[Quiz10Pt]+[MidtermWritPt]+[FinalWritPt]+[Proc1Pt]+[Proc2Pt]+[Proc3Pt]+[Proc4Pt]+[Proc5Pt]+[Proc6Pt]+[Proc7Pt]+[Proc8Pt]+[Proc9Pt]+[Proc10Pt]+[Proc11Pt]+[Proc12Pt]+[Proc13Pt]+[Proc14Pt]+[ProcPracPt]
I think this should be no complicated expression (though a bit long) and should just add the fields together. But what I get is that the calculated field appears as expected for records with an odd primary key (1, 3, 5, 7, ...) and turns out blank for records with an even primary key (2, 4, 6, 8, ...)!
I've attached a screenshot.
View 6 Replies
View Related
Nov 21, 2012
I have a table (tbl Team Info) which contains names and codes for teams within my business (>400 records) and another table (tbl Process) which contains a list of high level tasks (30 records).
I need to create something where for each team name 9in tbl Team Info) I can map them to the tasks that they undertake (in tbl Process) and assign a percentage of time then spend on each task. Each team could map to several different tasks.
View 3 Replies
View Related
May 29, 2014
In my simple database (attached), I need to mass duplicate Tasks and their Notes.
I have three tables: tbTasks (PK: Task_ID), tbNotes (PK: Note_ID), jtbTaskNotes (FKs: Task_ID and Note_ID). jtbTaskNotes is my many-to-many junction table that ties Tasks to Notes.
The main form (fmTasks), bound to tbTasks, has a subform (sbfm_TaskNotes) that displays notes associated with each Task. On themain form,you select which Tasks you want duplicated via a checkbox. The append query (quCopyTasks) will duplicate all tasks that have the checkbox checked. All good there. However, I can't figure out how to also duplicate each task's Notes.
I found Allen Browne's solution [URL] ....., but that only handles duplication of one record at a time, whereas I need to duplicate many records at a time (sometimes 10+ records). How do I go about duplicating multiple Tasks and their associated Notes?
Before you ask "why are you duplicating records?": There are times when tasks need to be re-accomplished and therefore need to have a new record. It's easier to duplicate records than it is to hand-jam everything again.
View 5 Replies
View Related
Jun 27, 2013
I am trying to get the records on start and end date, still showing error no records found.
My code is like this:
Private Sub Command90_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strReport As String
Const strcJetDate = "#dd/MM/yyyy#"
[code]...
View 1 Replies
View Related
Mar 22, 2013
One shows my form with the Transporters Subform with 3 entries, and 1 entry.The three line items that say "Transporter" are in one subform. I used this code
Code:
Private Sub Form_Current()
If Me.RecordsetClone.RecordCount >= 3 Then
Me.AllowAdditions = False
End If
End Sub
to limit the number of records I can add to 3 or less.My issue is that I lost the blank text box that allows you to add another record. So, if I only have one Transporter listed, there's no box to let me add a second or third.I have the following properties for the Transporters Subform set to "Yes":
Data Entry
Allow Additions
Allow Deletions
Allow Edits
Allow Filters
View 3 Replies
View Related
Nov 16, 2004
I have built a qry that initially shows the correct information. For example.
tblContent has 289 records with a Type = Class.
I built a Query to select from tblContent Type = Class and I get 289 records. I add additional criteria of Progress <>"Not Scheduled", I then get 206 records. I then add additional criteria Last Name <>"Demo" And <>"Care" And <>"Support". This brings up 200 records, but the query appears to duplicate each record 3 times. I do not have 3 of the same types of records.
The SQL Statement is below
SELECT tblProfile.LoginName, tblProfile.FirstName, tblProfile.LastName, tblProfile.Organization, tblProfile.CostCenter, tblContent.Title, tblContent.Type, tblContent.Code, tblContent.[Date Assigned], tblContent.[Date Started], tblContent.[Last Accessed], tblContent.Progress, tblContent.[Date Completed]
FROM tblProfile INNER JOIN tblContent ON tblProfile.LoginName = tblContent.LoginName
WHERE (((tblProfile.LastName)<>"Demo" And (tblProfile.LastName)<>"Care" And (tblProfile.LastName)<>"Support") AND ((tblContent.Type)="Class") AND ((tblContent.Progress)<>"Not Scheduled"));
The qry is named qryPhysical Class. I have provided the link to view the database. Can you help me?
http://briefcase.yahoo.com/turnerbkgabrobins
Thank you in advance for your assistance.
View 1 Replies
View Related
Dec 12, 2014
I have a form which needs update ever month. When the form is opened, the end user can see the old records and data, and also a new record is added for any new data. I want to protect the old saved data and the user can only add, edit, or delete the new data in the newly added record. The problem is once a user adds the new data and moves to another record or another form, then he/she cannot edit or change the new data in case if there is any mistake or need to change something after couple of minutes.
I changed the Form Data Properties "Allow Additions", "Allow Edits", and "Allow Deletions" many different times and situations to solve this problem but with no success. I tried the following with NO success too: One of the Fields of the Record is (Month). In the Data Properties, I set a Default Value for this field as(December 2014) for instance. I set the Data Properties "Allow Additions", "Allow Edits", and "Allow Deletions" to (Yes). Then I put the following code in the Form's Current Event:
Private Sub Form_Current()
If Me.month.Value = "December 2014" Then
Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True
[Code] ....
View 3 Replies
View Related
Oct 16, 2014
I have a table with about 1,2million records. I get an Excel list of about 35000 weekly, using which the table has to be updated: the records, that exist get fields updated, the ones that are new have to be added.
What is the fastest way to do this?
I'm trying with this code, but it's awfully slow, even if I read the update ranges into memory:
Code:
Set cn = CurrentProject.Connection
Set Rs = New ADODB.Recordset
Rs.Open "Select * from tbl_TTextract", cn, adOpenDynamic, adLockOptimistic
i = 2
Do While i < lr_2 + 1 'update
With Rs
[code]....
View 14 Replies
View Related
Jun 11, 2013
I need the following code to take data from a form and input it into two tables linked by the item ProjectID. My Code is as follows:
Code:
Dim pDate As Date
Dim fid, jan As Integer
Dim leng As Double
Dim strSQL As String
Dim varItem As Variant
pDate = Date
[Code] ....
I take the items that I'm putting into DailyT to track the date, foreman, Job Number, and how long they spent on the job. I got the DailyT part figured out.
What I don't know how to do is use the items in the list box lstSel and put them into the table ProjectT so that each record in ProjectT has the ProjectID from DailyT and the ActivityID that comes from the items in the listbox.
I know I'll need a loop but I don't know how to get the autonumber ProjectID (or define it) from the entry that I made in DailyT to put into ProjectT.
View 3 Replies
View Related
Mar 17, 2014
I want to sum up specific records in a table called TNS.
All records with Division = Common should be summed up to
the records with Division = AK.
TNS contaıns columns Division, 012013,022013...,122013
I tried following without success:
Code:
Public Sub TEST22()
Dim strSQL As String
strSQL = "Update TNS Set [012013] = 0.5 * DLookup([012013], TNS, Division = 'COMMON') " & _" Where Division IN ('AK') "
DoCmd.RunSQL strSQL
End Sub
It shows me following error:nAccess doesn't recognize TNS as a valid field name or expression. Something is missing in this syntax.
View 3 Replies
View Related
Feb 14, 2005
Hi
i have a small access program set up and it all works except one item, there is a sub table that we would like to add in information relating to the order number etc:
order number 1
sub table would have j number 12345
allocation 5
and j number 56789
allocation 25
order number 2 (new record)
could have j number 148
allocation 1
j number 2143213
allocation 12345555
j number 86868
allocation 34
etc
then when you move between each order the information in the table will show the specific information relative to the order number
at the moment when you move from record to record it clears the fields but enters the information into a table
hope this makes some sort of sense
any assistance would be gratefully received
best regards
kev
p.s.if it would i could attach a copy of the database
View 5 Replies
View Related
Aug 9, 2006
Hi all!!
I've inherited a new db that was created by folks fresh out of school.
I've been looking through it, checking to see how they built it, trying to scope out any neat and nifty new tricks they've used, before something goes wrong and I have to work on it.
They have a table that displays grouped records, and I'm not sure how they did it.
For example:
In the PRODUCTS table, the first record is for [Product Type] "Sticky Stuff", [Product Name] "GooGoo", [Manufacturer] "XYZ Co.", etc, with a + sign in front of the record.
When you expand the record, you get what looks like a sub-table listing all the transactions having to do with "GooGoo".
While trying to figure out how they got this effect, I checked out the Inventory Management sample db that's available on-line. They also have this type of grouped records in a product table.
Is there a simple explanation of how this is done, or do I need to invest some serious study time?
As always, thanks for any guidance you can give me.
Froggiebeckie
View 3 Replies
View Related
Mar 9, 2008
How do we create a subtable in access. When you open a table. First column come with + singn. When you click the + sign you get another sub table. How do we creat that table. What is the purpose of this table?
regards,
- Mahen
View 5 Replies
View Related
Jun 3, 2015
I am importing about 1.5 million records from a .txt file into an Access database. I have the code that splits the records and adds them to the database. However, the database has a 'specialty' table that lists certain specialty codes. The incoming record has a field that is a specialty code. Any way to search the 'specialty' table for the code that is coming in on the record to be added, and then, if the record 'code' is not found, skip it, and if it is found, add it to the database. There are about 70 codes in the 'specialty' table.
View 9 Replies
View Related
Dec 27, 2013
I am new to MS Access and using MS Access 2013.I just added 50 new fields into a table. I need to update these new fields on every record.The table layout is as followed:
Table1
-Company Id
-Question1
-Question2
-Question50
[code]....
View 6 Replies
View Related
Jun 29, 2013
What would be the Access 2007 VBA code for checking for duplicate records?
View 14 Replies
View Related