Modules & VBA :: Edit Junction Table - Unbound

Jun 11, 2015

New to access (and this forum) and working on a small db that includes the following tables:

tbl_Orders
tbl_Junction (Order Details)
tbl_Products

While the form itself is bound to tbl_Orders I decided to use unbound text boxes to enter the data (knowing I was in for some work!). Reason is that if textboxes were bound would need to use a subform with multiple combo boxes and that UI did not seem suitable for the application.

I’ve completed the code to add new records to tbl_Orders and tbl_Junction from the unbound textboxes. I'm using the VBA .AddNew method and is working well. Now I need to integrate code that will allow users to edit existing records while they are viewing them on the form.

I have the code to look up the record set I want to edit in tbl_Junction and am familiar with the .Edit method but the issue is that the required changes MAY include not just editing existing records but also deleting and adding new records. For example, the initial order may have been for Apples and Oranges and the revised order may change the number of Apples, eliminate Oranges entirely, and add some Bananas. So, it seems I need to .Edit Apples, .Delete Oranges, and .AddNew Bananas?

Should I try to write code to determine where I need to .Edit/.AddNew/.Delete? -- not looking forward to that. Thought maybe could delete the entire junction record set and then just .AddNew for everything per the revised order. That should work as the display on the form would be correct for the whole order. But maybe would cause a problem as would remove the FK in tbl_Junction that corresponds to the PK in tbl_Orders?

View Replies


ADVERTISEMENT

Unbound Combo Boxes And A Form With Allow Edit Set To 'NO'

Oct 29, 2005

Hi folks,

I have a form with a record source property set to a query which pulls the data by joining two tables. The form also has four navigation buttons (first, previous, next, last) and a ADD record, SAVE record, EDIT record, DELETE record buttons.

I also have a unbound combo box (control source iset to 'empty') in the form's header section and its record source property set to an SQL (SELECT DISTINCTROW tblProjts1.chrProjectName, tblProjts1.intProjectID FROM tblProjts1 ORDER BY tblProjts1.chrProjectName;). It's columns count is 2, bound column is set to 2 and column width is set to 3.1146";0".

In the edit button, I have the code "Me.AllowEdits = True" so that the user can edit the data.

Also, I have the following code on form's "on current" and "after update" events so that it will flip back to allow edit to 'NO'
Me.AllowEdits = False

Also, I have the following code on the combo box's 'after update' event.
Dim strSearch As String

strSearch = "[intProjectID] = " & Me![cboProjectID]

'Find the record that matches the control
Me.Requery
Me.RecordsetClone.FindFirst strSearch
Me.Bookmark = Me.RecordsetClone.Bookmark.

My Problem:

When I run the form and select a record from a combo box it populates the fields (all memo data type) in the form with correct linked record, ONLY when my allow edit property is set to 'YES'.

With allow edit set to 'NO', then when a tried to make a selection from a combo box it doesn't allow me to select any record. The combo box seems to be locked up and I can't select any record.

Does anyone come across such a problem with cbo box and 'allow edits' property in the forms.

Your help is much appreciated.

ShanVel

View 2 Replies View Related

Unbound Checkbox To Edit Selected Records

Dec 8, 2006

Hi i have a shared database and have a form with a string of records. Each record has its own unbound checkbox and I want to make it so you can select multiple records, then be able to hit a button on the top of the form to edit certain fields of the records selected. Please keep in mind that this is shared by 10 users, therefore a linked yes/no field would cause problems between the users.

View 2 Replies View Related

Modules & VBA :: Edit Specific Row In Table

Dec 30, 2013

I have a report that I run which has PT_Ins_ID in it, I am trying to edit that row with the following code.

Code:
Private Sub cmd_Deact_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("dbo_Patient_Insurance")
If rs.RecordCount <> 0 Then
With rs

[code]....

I've also tried this.

Code:
Dim rs_PI As DAO.Recordset
Set rs_PI = CurrentDb.OpenRecordset("dbo_Patient_Insurance")

[code]...

View 6 Replies View Related

Data Disappearing From Unbound Text Boxes Upon Edit.

Jan 12, 2006

Hello,

I have a form that utilizes a combo box called cboProgAddr (for Program Address). The cbox has 5 columns each of which fills in an adjacent text box. Since I needed the option of making corrections to these text boxes once they were filled in I need to set them up as unbound via the following code in the After Update event of cboProgAddr:

Private Sub cboProgAddr_AfterUpdate()
Me!txtProgStreet.Value = Me!cboProgAddr.Column(1)
Me!txtLocStreet.Value = Me!cboProgAddr.Column(1)
Me!txtProgCitySt.Value = Me!cboProgAddr.Column(2)
Me!txtLocCitySt.Value = Me!cboProgAddr.Column(2)
Me!txtProgZip.Value = Me!cboProgAddr.Column(3)
Me!txtLocZip.Value = Me!cboProgAddr.Column(3)
End Sub

As you can see it puts each field of data into two separate text boxes. Here's the issue: If I have to go back to the form after the original data entry the following boxes are blank...

txtProgStreet
txtProgCitySt
txtProgZip

while the following retain the orginal data...

txtLocStreet
txtLocCitySt
txtLocProgZip

The original cboProgAddr maintains its original data. All six fields above are stored in the same table as text field. I'd like all the boxes to maintain the data from the original input.

I'm totally baffled why this is so. I've attached images of the combo box control functions if that helps.


Thanks,
David

View 1 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 :: Unbound Text Box To Update Value Of A Table

Apr 10, 2014

So I have this code in an afterupdate event in an unbound text box to update the value of a table if the textbox is updated:

Code:

Private Sub txtCustRepID_AfterUpdate()
'Go to Calls table and find original value for CustRepID
'Fin the Call ID first
Dim CallIDVar As Long
Dim ContactIDVar As Long
Dim CustRepIDOr As String
CallIDVar = Forms![Contacts]![Call Listing Subform].Form![CallID]

[code]...

This code works well when entering numbers in the text box but it returns error 3061; "Too few parameters. Expected 1" when along with the numbers there is a letter in the textbox.The error happens in this part of the code:

Code:
'Accept change and add new value to table
CurrentDb.Execute _
"UPDATE Calls " & _
"SET CustRepID = " & CustRepIDNew & " " & _
"WHERE CallID = " & CallIDVar, dbFailOnError

The underlying table has text as type of data for this field.

View 2 Replies View Related

Modules & VBA :: Unbound Forms Information To Table

Jan 13, 2014

I've tried using the vba to have unbound forms information pasted to a table. The Vendor, Channel and Department are unbound fields in the form and I can't, for the life of me, figure out how to get them to append to the table.

I've tried using solutions provided prior but I must be missing something. Here's my database. I'd like for it to append to the table then ready the form for the next entry.

View 14 Replies View Related

Junction Table Help

May 29, 2005

I am trying to set up a Real Estate database, and can't get the Relationships to work. I have three tables:

House Listings
Farm Listings
Clients

Clients can have properties in both House and Farm Listings Tables, so I need a Junction Table (or do I need more than one?)

The Primary Key fields of House Listings Table (HouseID) and Farm Listings Table (FarmID), become a composite Primary key in the Junction table. Is this correct?

Both the House Listings Table and the Farm Listings Tables have a field for Client ID. Is this causing me problems, as I can get the Farm and Clients Queries to work, but not any queries with the House Listings.
As this is my first attempt at creating a database with many-to-many relationships, please explain in simple terms what I am doing wrong.

I would appreciate any help.

Thanks

View 2 Replies View Related

Modules & VBA :: Insert Unbound Field Values Into A Table?

Mar 11, 2015

I am working on a timesheet application which allows users to insert multiple timesheet entries in a grid style format. the first row is visible and to add another row users click on a command button which makes the next row of fields available and ready to fill in and so on and so forth. I need the fields to be unbound and then when the user clicks on a save button for example then it inserts those values into the relevant table. Table name is tbltimesheet, field names are id, companyname, project, activitydate, activityhours, activitynotes, username, userid

View 2 Replies View Related

Modules & VBA :: Getting Blank Lines In Table Even Though Form Is Unbound

Jun 24, 2013

I have created a forum that all fields are unbound. On completing it is written to the table using a RunSQL command. This writes to the table with no problem but when it does so it is creating another entry with zero content. This is the save steps with open new form

Code:
Private Sub SaveRecordAddNew_Click()
Call PreSaveCheck
If Me.saveCheck = False Then
Exit Sub
Else
Call WriteToTable

[Code] .....

View 12 Replies View Related

Modules & VBA :: Populating Unbound Textboxes With Data From A Table

Aug 7, 2014

I want to know a way of populating unbound textboxes with data from a table without using the easy assigning data in the property of the box. I want it to be all done with code, which to me isnt a huge deal but I've yet to find answers on the web pertaining to this issue.

for example:

Say i was searching a primary key in one box and based on what ever is typed in i'd like it to populate the rest of the textboxes.

View 1 Replies View Related

Modules & VBA :: Using Unbound Form Values To Update Table

Jul 16, 2015

I have an unbound form in which a user enters data relating to a credit dispute, and when they hit the Save button I have a sub that is intended to insert that data into a table. This is a bit out of my comfort zone, so I found some code from another forum and adjusted it to my needs. However, I'm getting errors.

The table name is tbl_complaints. The fields from the form are:

txtAcctNumber
txtClient
txtEoscarType
txtEoscarControl
cboMethodReceipt
....

My code is below.

Private Sub cmdSave_Click()
Dim StrSql As String
On Error GoTo ErrorHandler
StrSql = "INSERT INTO tbl_complaints " _
& "(ACCT_NUMBER, CLIENT_NAME, EOSCAR_TYPE, EOSCAR_CONTROL_NUMBER, METHOD_OF_RECEIPT,

[Code] ....

The error I get is error number 3075, and it says I'm missing an operator in the section that references cboResponseType, but I can't seem to figure out what I'm missing. My head is spinning from staring at these parentheses and apostrophes for so long.

View 14 Replies View Related

Need Help With Junction Table(s) Construct

Apr 13, 2007

I'm working in the petro-chem and industrial service industries now, and am finding there are relationships I haven't had much exposure to in the past.

Can someone please help me with constructing the tables and relationships needed here?

This is something I should probably know, yet I've never created junction tables which must take into account nested data. I have created a relationship which works, but I feel it could be done in a simpler fashion.

By the way, I cannot find Pat Hartman's many-to-many sample db. It is either missing, or the restrictions on word length in Search just aren't letting me find it.

Table: WorkOrder is the primary table I'm working with. I need to store 4
pieces of information for every WorkOrderID, two of which have subs.

Here's a picture of the data I need to collect:

View 4 Replies View Related

Junction Table Needed??

Apr 24, 2006

I’m having trouble defining Relationships I’m thinking I need a “Junction” Table and I have tried looking at the Orders.mdb but it hasn’t helped (I’m sure I’m just missing something) I just don’t see how it works. If at all possible please don’t just give the info try to help me understand so I can get the answer myself.
Here is what I have:
Far table:
FarNumID (PK) > autonumber
FarNumber > Text “224-10C”
FarTitle> Text

FarParagraph table:
FarParaID (PK) > autonumber
FarNumID > Number
FarParaTitle > Text
FarParaText > Text

AC table:
ACNumID (PK) > autonumber
ACNumber > Text
ACTitle> Text

ACParagraph table:
ACParaID (PK) > autonumber
ACNumID > Number
ACParaTitle > Text
ACParaText > Text

1. Each FarNumber can have only 1 FarTitle 1:1
Each FarNumber can have many FarParaTitles 1:Many
Each FarNumber can have many FarParaText 1:Many
2. Each FarTitle can have many FarParaTitle 1:Many
Each FarTitle can have many FarParaText 1:Many
3. Each FarParaTitle and have only 1 FarparaText 1:1

Thanks so much.

View 4 Replies View Related

Junction Table Ans Subforms

Dec 8, 2005

All I ever seem to do is sit about trying to figure this out and then give up and ask for help :(

I have three tables.

One for contacts
One for groups (groups like people attending meeting a, b c)
and a junction table as the top two create a many to many relationship.. one person can be part of multiple groups, and a group can have multiple members.

In the contacts table my primary key is an auto number, and is contactsID
I also have some contact details, and a groupID field

In the group table my primary key is GroupID and is an auto number,
it also have group name, and description

in the junction table I have a primary key, then GroupID, and ContactsID which are also set at primary keys and are set with the same values as the same named primary keys in the relavant tables (I beleive this defines them as foreign keys... i hope so anyway!)

I have the relationships set up as a one to may relationship from contacts to junction and groups to junction, contacts linking from ContactID to ContactID in each table, likewise with the Group table.

However, when I try to put everything into a main form for contacts,with a subform for groups, all I am getting is the autonumber... which isn't much good for my end user..... :( How do I solve this?

Thanks anyone that can help.......

View 3 Replies View Related

Modules & VBA :: Add Records In Table Through Button From Unbound Text Box And Combo Box

Jun 27, 2013

how to add recoreds in table thru form. There are 10 fields. first two are txt boxes and rest of are combo boxes. combo box are with drop down list. But they are unbound. two txtbox are auto filled by the username and empid. Now need to write the code to update these value to table. Just i wanna do ti thru vba coding only.

View 1 Replies View Related

Junction Table Record Additions

Dec 5, 2007

I'm trying to add records to a junction table based on additional record added to one table via form in the many to many relationship.
Junction table = ClientAssociation
Main table = ClientMain (qry_NewClientNullAssociation identifies new record added)
Many to many table = Associations

I'm trying to do this upon clicking a command button that then opens ClientAssociation based on Client_ID. Then allows user to select mutliple associations (Asoc_ID) for Client_ID.

Here's what I have - I'm new at this...

Private Sub ClickAssociations_Click()
On Error GoTo Err_ClickAssociations_Click

'Open recordset with new client records
Dim db As Database
Set db = CurrentDb
Dim recClient As DAO.Recordset
Dim strClientID As String


Set recClient = db.OpenRecordset("qry_NewClientNullAssociation", dbOpenDynaset)
'Loop through new client ids
Do While Not recClient.EOF
strClientID = ClientMain.Client_ID

Dim recAsoc As DAO.Recordset
Dim strAsocID As String

Set recAsoc = db.OpenRecordset("Association", dbOpenDynaset)
'Loop through asoc ids
Do While Not recAsoc.EOF
strAsocID = Asoc_ID

'Open junction table and update records
Dim recClientAsoc As DAO.Recordset

Set recClientAsoc = db.OpenRecordset("ClientAssociation", dbOpenDynaset)
With recClientAsoc
.AddNew
!Client_ID = strClientID
!Asoc_ID = strAsocID
!CheckBox = False
.Update
End With

recAsoc.MoveNext
Loop

recClient.MoveNext
Loop

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Associations2"
stLinkCriteria = "[Client_ID]=" & Me![Client_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ClickAssociations_Click:
Exit Sub

Err_ClickAssociations_Click:
MsgBox Err.Description
Resume Exit_ClickAssociations_Click

End Sub

View 1 Replies View Related

Data Entry In A Junction Table

Dec 18, 2007

Hello all,

I just wanted to run this by some experts before I go mucking around in my db. Basically, I am creating a data entry form to populate with information about car parts, and the vehicles they apply to. This is what I am working with:


tblParts tblModelsParts tblModels
PartID ModelPartID ModelID
PartNumber PartID ModelNameID
PartDesc ModelID ModelYearID

I am trying to build a form that will allow me to enter new part numbers and descriptions into the table, and then have the user select (through a listbox?) all the vehicles the parts apply to. Is there a way to populate the junction table with each combination of partID and ModelID automatically? NOTE: tblModels is already populated with data.

I am assuming there would be a way to do this... A query of the junction table (and tblModels?) as the recordsource for the form, and then a subform with the tblParts as its recordsource?

I would have posted this in the massive thread I have going already... but I thought it might be nice to give Craig and Adam a break from helping me :o

View 14 Replies View Related

Junction Table -number Or Autonumber?

Dec 21, 2007

Hi :)
I have solved a m:n relationship by adding a junction table. The composite primary key in the junction table is made up of primary keys from the other two tables, and both of theses primary keys are set to autonumber.

My question is this: Is it correct to set both parts f the composite key in he junction table to number rather than autonumber?
I was thinking that since autonumber should be set only once, the junction table should just take on what ever value there is in the primary keys of the other two tables.

Kind Regards
Marie

View 3 Replies View Related

Normalization: One-to-many Out Of A Junction Table Without A Primary Key

Apr 8, 2008

Hello,

I have attached a screenshot of the relationships in (a section of) a database I am working on. Would anyone please be willing to view it and offer any suggestions as to whether is fully normalized or not? Here is the description:


An account [table, Account] consists of some money. That money is split-up and invested into several different places.
The funds that are available as choices are in Fund; the funds that are chosen are in InvestmentInstance. Different, unaffiliated accounts can invest in the same fund. I would like to keep track of when an account begins to invest in a fund and when it stops investing there (“InceptionDate” and “CloseDate”).
The generic, account-independent performance of a fund is kept in Price, where the values come from Yahoo! Finance or something like that.
Similar to Price, MarketValue stores the dollar-amount of an investment, specific to an account.

I think I have most of it set OK, but my main concern is about the relationship between InvestmentInstance and MarketValue. As the picture shows, I use InvestmentInstance’s “Id”* as the “one” in the one-to-many relationship, but “Id” is not a primary key. To get it to work, it was necessary to set the Index option to, “Yes (No Duplicates),” so that it was a unique index. Is this a bad practice? Should I just include “Id” as part of the compound primary key? I didn’t think making it part of the compound key was a good idea because then it would defeat the purpose of having “FundId” and “AccountId” control the uniqueness of records. Am I missing something important?

In other words, how can I correctly create a one-to-many relationship that begins in a juntion table (InvestmentInstance) and connects to a new table that was not involved in the normalized many-to-many relationship (MarketValue)?

Thank you!



* I know many like to include the table name in the ID, like, “InvestmentInstanceId,” and it is only my preference to keep it just as “Id” for a local key for simplicity, but add the table name when it becomes a foreign key. I feel “Id” is good enough for my purposes and it’s table location is usually clear from the context.

View 8 Replies View Related

Populating Junction Table From Form

Aug 31, 2011

I am trying to create a main form that selects a series of values allowing the user to enter new data or edit current data (using other forms). I have a series of cascading combo boxes that populate accordingly and become visible after update. I can successfully create the series and add new data and edit data as in my code.

How to populate the junction table from the forms so for example when editing or adding a new site it not only populates the tblSites and the tblSitesContacts it also populates the tblClientSitesJunction with values from the frmSites and also cmbClients. If I use the wizard and try and add values from all 3 tables to form it doesn't work and I am not sure how to add the ClientID and SiteID manually to frmSites.

I have attached a copy of my database :

Attachment 4334

View 14 Replies View Related

Modules & VBA :: Update Specific Record In Table Using Unbound Field On Form

Dec 4, 2013

How to do an UPDATE using VBA on a form to update a specific record on the table using an unbound field on the form to filter the update.

Every time the code runs, it tells me: Run-time error '3144': Syntax error in UPDATE statement and takes me to the "CurrentDb.Execute strSQL, dbFailOnError" line at the end of my sample below.

Here's my code:

Dim strSQL As String
Dim strCriteria As String
strSQL = ""
strSQL = strSQL & " UPDATE [tblTicket] SET"
strSQL = strSQL & " ([UpdatedBy], [AssignedTo], [Requestor], [Dept])"
strSQL = strSQL & " Values"
strSQL = strSQL & " ('" & unbEnteredBy & "','" & cmbAssignedTo & "','" & cmbRequestor & "','" & cmbDepartment & "')"
strSQL = strSQL & "Where [tblTicket]![DateTimeOpened] = #" & FORMS!frmTicketTracker.unbDateTimeOpened & "#;"
CurrentDb.Execute strSQL, dbFailOnError

View 9 Replies View Related

Linked Tables Not Updating In Junction Table

Nov 20, 2004

Hi, I have the following structure:

Products 1-M ORDER DETAILS M-1 ORDERS M-1 CUSTOMERS

I have ORDER DETAILS set as a junction table so that many products can be recorded within one order. All is good apart from when i go into ORDERS and create a new order. I click the subform which links to the ORDERDETAILS. I then pick a product number(look up from products table). The problem is this: In the ORDER DETAILS I want to display the unit price of this product simply by picking the product id.

Eventually this would form the basis of an order form where I can pick Product Id and have it display unit price.

Any ideas on this one, I'm sure its quite simple!!

Thanks in advance

View 1 Replies View Related

Multiple Delete Query With Junction Table??

Dec 14, 2007

Hi there.

I'm trying to archive records by using append and delete queries that span accross 12 tables.

the VBA will execute them all. However, I have a junction table near the end; It will be the Junction table, then a parent then a child table. I can get the junction table keys deleted but after that I can't get the Parent and the child table records deleted.

Does anyone know how to do this. the parent table can't delete any records because I've deleted the junction table keys first but if I delete the parent table keys access obviously wont let me because it's leaving orphan records.

I'm sure there's a way to do this. hope someone can help me.

Thanks.

View 2 Replies View Related

Queries :: Junction Table In A Ternary Relationship?

Nov 14, 2013

I explain , i have 5 tables :

Class ( classID , classname,... )
Student (studid , firstname, lastname , classID ,....)
Course( courseid , coursename )
Term ( termid , termname , begindate , enddate )
Score ( scoreid , studid , courseid , termid , score)

Note :

1) A class can contain one or more students (one-to-many between Class and Student tables)

The table "Score" is a junction table between three tables : Student , Course and Term because it contains three foreign keys ( I could use a combination of 3 foreign keys to make a primary key ! ) .

The tables ; "Class", "Student", " Course ", "Term " already contain data for each table I created a data entry form .

My biggest problem is how to create a form to enter students' grades for each class.

On the form I would like to use ComboBox to select a class that displays students from this class then another ComboBox to select course and another ComboBox to choose the term and then enter grades or scores for each student.

View 3 Replies View Related







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