473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Saving changes to records on a form

Hi,

I have a form that is a combination of comb boxes and text boxes which functions as a means to to lookup records, taking the information from several different tables. The text boxes are all populated via Dlookup in an after update event from a combo box.

What I want to be able to do is to be able to edit and add information to records where some of the text boxes are not populated. What would be the best way to achieve this?

Thanks in advance for help with this issue.
Jul 22 '19 #1
13 4070
twinnyfo
3,653 Expert Mod 2GB
AdmiralN,

I think we can help you with this, but we will need considerably more detail before we can start.

First, it's not entirely clear what it is you are describing with [qoute]What I want to be able to do is to be able to edit and add information to records where some of the text boxes are not populated.[/quote]

In general, editing and saving information to records is relatively easy, but you may have thrown us a curve in your description.

Thanks for any additional information you can provide.
Jul 22 '19 #2
Hi Twinnyfo,

Thanks for your response. Hopefully I can explain my issue a bit clearer below.

To give a bit of background, for my database I started with importing a single sheet excel file. This is my first database so I'm aware I've probably made some mistakes with how I've set this up.

I currently have 4 tables, tblActvity, tblID, tblPackages and tblUnitPeriod. I also currently have a single unbound form which contains 2 cascading combo boxes cboPackageNumber and cboActivity, which serve to populate a number text boxes with the rest of the information for each record from each table. Below is the code I'm using for the after update event.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub btnAddNewRate_Click()
  4.  
  5. End Sub
  6.  
  7. Private Sub cboActivity_AfterUpdate()
  8.     Me.cboRateHigh = _
  9.         DLookup("ProductivityRateHigh", _
  10.                 "tblUnitPeriod", _
  11.                 "ID=" & Me.cboActivity)
  12.     Me.cboRateLow = _
  13.         DLookup("ProductivityRateLow", _
  14.                 "tblUnitPeriod", _
  15.                 "ID=" & Me.cboActivity)
  16.     Me.cboUnit = _
  17.         DLookup("Unit", _
  18.                 "tblActivity", _
  19.                 "ID=" & Me.cboActivity.Column(1))
  20.     Me.cboTimePeriod = _
  21.         DLookup("[Time Period]", _
  22.                 "tblActivity", _
  23.                 "ID=" & Me.cboActivity.Column(1))
  24.     Me.cboSource = _
  25.         DLookup("Source", _
  26.                 "tblID", _
  27.                 "ActivityID=" & Me.cboActivity.Column(1))
  28.     Me.cboNotes = _
  29.         DLookup("Notes", _
  30.                 "tblID", _
  31.                 "ActivityID=" & Me.cboActivity.Column(1))
  32.     Me.cboMax = _
  33.         DLookup("LeadTimeHigh", _
  34.                 "tblID", _
  35.                 "ActivityID=" & Me.cboActivity.Column(1))
  36.     Me.cboMin = _
  37.         DLookup("LeadTimeLow", _
  38.                 "tblID", _
  39.                 "ActivityID=" & Me.cboActivity.Column(1))
  40.  
  41.     If cboPackageNumber > 0 Then
  42.         cboPackageNumber.Enabled = True
  43.         cboActivity.Visible = True
  44.         Me.cboRateHigh.Requery
  45.         Me.cboRateLow.Requery
  46.         Me.cboUnit.Requery
  47.         Me.cboTimePeriod.Requery
  48.         Me.cboSource.Requery
  49.         Me.cboNotes.Requery
  50.         Me.cboMax.Requery
  51.         Me.cboMin.Requery
  52.     Else
  53.         cboActivity.Enabled = False
  54.     End If
  55.  
  56. End Sub
  57.  
  58. Private Sub cboPackageName_AfterUpdate()
  59.  
  60. End Sub
  61.  
  62. Private Sub cboPackageNumber_AfterUpdate()
  63.     Dim strSql As String
  64.  
  65.     strSql = _
  66.         "SELECT o.RateID, o.ID, o.Activity, o.[Time Period], o.Unit " & _
  67.         "FROM tblActivity AS o " & _
  68.         "WHERE o.PackageID = '" & cboPackageNumber.Value & "'" & _
  69.         "ORDER BY o.PackageID;"
  70.     Debug.Print strSql
  71.     cboActivity.RowSource = strSql
  72.  
  73.     If cboPackageNumber > 0 Then
  74.         cboPackageNumber.Enabled = True
  75.         cboActivity.Visible = True
  76.         Me.cboActivity.Requery
  77.     Else
  78.         cboActivity.Enabled = False
  79.     End If
  80.  
  81. End Sub
  82.  
  83. Private Sub Form_Current()
  84.    Me.saveRecord.Enabled = False
  85. End Sub
  86.  
  87. Private Sub Form_Dirty(Cancel As Integer)
  88.     Me.saveRecord.Enabled = True
  89. End Sub
  90. '------------------------------------------------------------
  91. ' btnAddnew_Click
  92. '
  93. '------------------------------------------------------------
  94. Private Sub btnAddnew_Click()
  95. On Error GoTo btnAddnew_Click_Err
  96.  
  97.     On Error Resume Next
  98.     DoCmd.GoToRecord , "", acNewRec
  99.     If (MacroError <> 0) Then
  100.         Beep
  101.         MsgBox MacroError.Description, vbOKOnly, ""
  102.     End If
  103.  
  104. btnAddnew_Click_Exit:
  105.     Exit Sub
  106.  
  107. btnAddnew_Click_Err:
  108.     MsgBox Error$
  109.     Resume btnAddnew_Click_Exit
  110.  
  111. End Sub
  112.  
  113. '------------------------------------------------------------
  114. ' btnSaveRec_Click
  115. '
  116. '------------------------------------------------------------
  117. Private Sub btnSaveRec_Click()
  118.     If Me.Dirty = True Then
  119.         DoCmd.RunCommand acCmdSaveRecord
  120.     Else
  121.         MsgBox "nothing to save"
  122.     End If
  123. On Error GoTo btnSaveRec_Click_Err
  124.  
  125.     DoCmd.SetWarnings False
  126. 2
  127. 'This will save a new record:
  128. 3
  129.     DoCmd.RunSQL "INSERT INTO tblID(LeadTimeHigh) VALUES('" & cboMax & "')"
  130. 4
  131. 'This will save value to existing record:
  132. 5
  133.     DoCmd.RunSQL "UPDATE tblID SET LeadTimeHigh='" & cboMax & "' WHERE ID=" & cboMax
  134. 6
  135.     DoCmd.SetWarnings True
  136.  
  137.     ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
  138.     ' <UserInterfaceMacro For="btnAddnew" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><Statements><Action Name="OnError"/><Action Name="GoToRecord"><Argument Name
  139.     ' _AXL:="Record">New</Argument></Action><ConditionalBlock><If><Condition>[MacroError]&lt;&gt;0</Condition><Statements><Action Name="MessageBox"><Argument Name="Message">=[MacroError].[Description]</Argument></Action></Statements></If></ConditionalBlock></
  140.     ' _AXL:Statements></UserInterfaceMacro>
  141.     On Error Resume Next
  142.     DoCmd.RunCommand acCmdSaveRecord
  143.     If (MacroError <> 0) Then
  144.         Beep
  145.         MsgBox MacroError.Description, vbOKOnly, ""
  146.     End If
  147.  
  148. btnSaveRec_Click_Exit:
  149.     Exit Sub
  150.  
  151. btnSaveRec_Click_Err:
  152.     MsgBox Error$
  153.     Resume btnSaveRec_Click_Exit
  154.  
  155. End Sub
I named the text boxes with cbo prefix instead of txt just to make it more confusing:)

What I would like to be able to do is update the records from the form where some of the text boxes are blank. I would also like to be able to add new records. I've tried adding a 'Save' button with the wizard and an 'Add New Record' button with the wizard but currently these buttons don't seem to do anything. I understand this is because my form is unbound.

I hope that makes more sense. Thank you again for any help you can provide.
Jul 23 '19 #3
twinnyfo
3,653 Expert Mod 2GB
To say that there is a "lot" wrong with your code would be an understatement, but please don't take that as an "eye poke", as you state you are new to this adventure. Let me try to start at the beginning, line by line (with the adjusted code above), and then ask a few more questions to try to make sense out of all this.

Line 2 should be:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
For whatever unconscionable reason, Microsoft does not default to forcing us to declare variables when we use them. This is a TERRIBLE habit to get into. From your VBA Editor, Tools | Options | Editor Tab | make sure "Require Variable Declaration" is checked.

Lines 8-39: It appears you are merely assigning values to combo boxes, but it doesn't appear that you are using these combo boxes anywhere else in your code (or very little of them). First, if you are merely assigning a value to the combo box (and not using the combo box as a combo box), why not just use text boxes? Again, I don't know everything that's going on with this form, but it appears you posted the code from the entire form? Second, several of the combo boxes have data from the same table. You are forcing the DB to query the entire table (in some cases) four times to access one recod on the same table. Again, you're not using this data for anything, but a more efficient way would be to use a recordset. Additionally, combo boxes usually have (at least) two columns of data, the first is an index or key (usually hidden) and the second (and following) values that make sense to the user. The "value" of a combo box is usually the index that is then used for other purposes. Lots here to understand about combo boxes and indexes.

Upon further review after finishing this entire response and re-re-re-reading your latest post:
AdmiralN:
I named the text boxes with cbo prefix instead of txt just to make it more confusing:)
As someone who's been doing this for quite a few years--yes, lots of grey hairs--and as a moderator, who's trying not to get kicked off a forum he's done a lot to help others on, all I can say (and this is the tamest language I can force myself to use at this point) is that this is the second most asinine thing I have ever seen someone do. The most asinine thing I've ever seen is a guy who designed a massive database in which all his table names and field names were jumbled 8-character puzzles, because, so he says, "He didn't want anyone to know what was in the tables and fields." As you can observe from the previous paragraph I wrote concerning combo boxes (and my COUNTLESS references to your "combo boxes" throughout), your naming convention matters. When you name a control cboWhateverYouWannaCallit, anyone reading this site is going to make one assumption: it is a combo box. Consider this your one and only repreive for being cute--I'm in a good mood today.

Line 41: cboPackageNumber does not appear to be changed or modified anywhere in the previous code, so it's value never changes. Yet, in lines 62ff., you have some code evaluating cboPackageNumber, performing much of the same activities, including making cboActivity visible if cboPackageNumber is greater than 0. I would argue that this evaluation in line 41 is unnecessary, as if the code ever gets to line 41, by definition, cboActivity is visible, because it was updated. More on this section of code below.

Line 42: cboPackageNumber was updated in order to get here, so it is already enabled and is never disabled anywhere.

Line 43: cboActivity was just updated to execute this line of code. By definition, it is visible.

Lines 44-51: Since you are merely assigning values to the combo boxes, and not assigning a new Record Source, there is no need to requery these controls.

Line 53: Again, since cboPackageNumber has already proven to be greater than 0 (to get here), this line will never be executed.

Lines 65-69: Again, a lot that is out of the ordinary here. While it is possible for you to assign many columns to a combo box, we would expect you to use them. In this case, you are using five columns, but only appear to use two. Some additional notes on this section:

First, the SQL itself. If you are querying from only one table, it is not necessary to refer to the fields explicitly using the TableName.FieldName syntax. Don't get me wrong, this may be a good habit to get into as you design more complex queries. Additionally, it certainly appears that cboPackageNumber stores a numerical value, yet you are using single quotes, implying that it is text (which can throw the DB off sometimes). Also, there is essentially never a reason to refer to a control's .Value property, as it is the default reference. Thus, for such a simple query, your SQL could be as easy as:

Expand|Select|Wrap|Line Numbers
  1.     strSql = _
  2.         "SELECT RateID, ID, Activity, [Time Period], Unit " & _
  3.         "FROM tblActivity " & _
  4.         "WHERE PackageID = " & cboPackageNumber & _
  5.         " ORDER BY PackageID;"
You may also observe that the Field [Time Period] requires square brackets around it. This is because Access doesn't like Fields with spaces, and this is how it treats the text as a single field. This is encouragement for us to create tables with fields that do not contain spaces. The Field Name "TimePeriod" would work equally well, and not require brackets.

Second, you are pulling this data from tblActivity, yet you are using Domain Query Functions (DLookup) to find data from tblActivity in two of your Combo Boxes (Unit and [TimePeriod]). You could use the value currently in cboActivity to update these combo boxes:

Expand|Select|Wrap|Line Numbers
  1.     Me.cboUnit = Me.cboActivity.Column(4)
  2.     Me.cboTimePeriod = Me.cboActivity.Column(3)
Notice how column numbering begins with 0.

Lines 70-71: BRAVO! Great habit to get into. This allows you to see what your SQL string looks like and even test it if you need to. This is a good practice. Great job!

Line 74: As mentioned before, cboPackageNumber was just updated. It is enabled.

Lines 90-111: You said this is an ubound form. You cannot move to a new record.

Lines 129, 133: First, you got it right in lines 70-71. Always create a string first, then act on it. Second, your first SQL statement adds a new record, assigning a value to LeadTimeHigh with the value of cboMax. Your second SQL updates the value of LeadTimeHigh to cboMax. There is no need for the second SQL to be executed, as LeadTimeHigh is already set to cboMax. Finally, exactly what is it you are doing here? Do these tables have just one field? It does not appear so, as in the second SQL statement you are trying to update based upon the ID being equal to cboMax. But you are assigning the value of LeadTimeHigh to cboMax. ???? Is LeadTimeHigh an index? Is cboMax an index? Is it another type of value? This code itself is just confusing as to what you want to update to what values.

Lines 137-140: ???????

Lines 142: You cannot save this record as this is an unbound form.

Lines 143-146: Not sure the intent here. You should use Err.[Property], as this is not a macro.

So, some additional questions: Really--what are you trying to do? Please, use small words for those of us who don't understand what your intent is: "I want to assign the values from these specific combo boxes to these tables under these specific conditions."
Jul 23 '19 #4
Hi twinnyfo,

First of all thank you so much for the your very detailed reply. It must take you considerable time to write a response such as that and I am incredibly grateful that people like you are willing to provide help to beginners like me for free.

As for the naming convention for the combo boxes, your point is dully noted. It was not something I considered when naming the text boxes, but I accept how confusing it must be for someone else trying to understand my code.

I hadn't considered how much crap I had in the code when I posted it on here. I have mostly been experimenting with trial and error, taking pieces of code from different sources, mainly forums such as this, and seeing what the affect was (if any) on the form.

I will take some time to work through your comments one by one to understand the errors. In the interim, it seems I have done a rather a poor job of explaining what I am trying to achieve. Let me see if I can explain better below.

My initial spreadsheet had columns:- Package No., Package Description, Activity, Productivity Rate High, Productivity Rate Low, Unit, Time Period, Notes, Source, Lead Time High, Lead Time Low. - Containing several hundred records, some of which were incomplete.

Package number and Description are effectively the same. The 'Activity' column contains activities under each package -these are unique records and each has a unique 'productivity rate high', productivity rate low', 'Source', 'Notes' and 'Leadtime High and Low columns.

My current form contains combo boxes for 'Package No' and 'Activity' and then text boxes for all the other fields. Currently I can select a package no and then the second combo box will filter for the activities within that package. Once an activity is selected the various text boxes (ProductivityHigh, ProductivityLow, Unit, Time Period, Source, Notes, Lead time - Max and Min) are populated with the rest of the information for that record.

The form currently works great as a means to look up records, but not much else. I would like to be able to add new records (i.e. add new 'Activities' and the details related.) and also to be able to edit existing records.

I'm also concerned my table structure isn't optimal. I currently have tables:-

tblPackages - with cols 'Package No', 'Package Description', 'ID' (PK)

tblActivity - with cols 'Activity', 'Unit', 'Time Period', 'ID'(PK), 'RateID', 'PackageID'.

tblUnitPeriod - with cols 'ProductivityRateLow', 'ProductivityRateHigh', 'ID'(PK)

tblID - with cols 'ID'(PK), 'Notes', 'LeadtimeLow', 'LeadTimeHigh', 'Source', 'ActivityID'

Thanks again.
Jul 24 '19 #5
Just some further updates as I'm working through your reply.

Lines 41-53 - I removed these as you correctly pointed out they were doing nothing. Originally I was trying to get the text boxes to clear once a new package number was selected. At the moment the values from the previous record remain visible until the cboActivity is selected.

Lines 65-69 -I acknowledge this code is confusing. I did swap it for the your simplified version, but I then lost the activities values in cboActivity. I also realize I could have populated some of the text boxes from cboActivity as they were present in the same table.

Line 74 -I've removed this as rightly mentioned, it does nothing.

Lines 90-111 - I removed this code for the button save. I think this was originally generated through the button wizard. But as you say would never work with an unbound form.

Lines 129, 133 -I had pasted from another forum post a piece of code I thought I could adapt to save edits to records. I was (and still am) in way over my head.

Lines 137-140 -I'm not even sure where that came from! :) Deleted.

Lines 143-146 - Again I'm confused what I was trying to achieve here. Deleted.

Also, I renamed the Text boxes with the 'txt' Prefix as you suggested.

Thanks!
Jul 24 '19 #6
twinnyfo
3,653 Expert Mod 2GB
A few quick thoughts:

Your spreadsheet has the following fields (we'll call them "fields" so that we maintain nomenclature continuity with a DB structure) "Package No., Package Description, Activity, Productivity Rate High, Productivity Rate Low[/b], Unit, Time Period, Notes, Source, Lead Time High, Lead Time Low". Here is my question: why split these fields out into different tables? I can only assume that they are exported to Excel (or are simply contained in Excel) as coherent "records"? Unless there is an absolute "need" to create separate tables, it is much easier to maintain the integrity of the records as is.

The 'Activity' column contains activities under each package -these are unique records and each has a unique 'productivity rate high', productivity rate low', 'Source', 'Notes' and 'Leadtime High and Low columns.
This is quite confusing! The Activity column has multiple columns? Please explain.

Finally, if you are using Excel as your source data, I can only assume that you have had some means to import the data into a table(s)? If you use one table (as described above), the simplest approach is to have a form bound to that table. Then you can add/modify/delete records and do whatever you want. Then you can view an entire record at a time. Unlesss I am missing something significant here, this would be your approach.

Standing by for greater details....
Jul 24 '19 #7
Hi twinnyfo,

The data was imported was imported from a single excel spreadsheet via the import wizard within access. I then used the table wizard to break the single table of records into several tables. In hindsight, as you have pointed out, this may have been a mistake. I had thought (for some reason) that is was better to have the records broken into different tables.

As for the Activity Column, what I meant was that all the activities are unique, but they may have the same package number. There is a finite list of Packages, each unique activity is assigned to a package (package number).

Hopefully I have explained a little better. Apologies for confusing the issue.
Jul 25 '19 #8
Ok so I have 're-jigged' the form so it is bound to 1 table with all the records. This is identical to the excel spreadsheet.

I have my text boxs all bound to the cboActivity to auto-popluate via the Control Source and relevant column. The issue now is if I try to edit the data in the text boxes it says 'Control can;t be edited as it's bound to the expression '[cboActivity].[Column]().

How can I make it allow me to edit the records?

The form properties option 'Allow edits' is set to yes.

Update- I changed to column assignment to the after update event of the cboActivity. I can now edit the text box fields again, but any changes I make to the fields are not saved back to the table.
Jul 25 '19 #9
twinnyfo
3,653 Expert Mod 2GB
I have my text boxs all bound to the cboActivity to auto-popluate via the Control Source and relevant column. The issue now is if I try to edit the data in the text boxes it says 'Control can;t be edited as it's bound to the expression '[cboActivity].[Column]().
I have no idea what this means.

Update- I changed to column assignment to the after update event of the cboActivity. I can now edit the text box fields again, but any changes I make to the fields are not saved back to the table.
I have no idea what this means.

Why do you have multiple combo boxes? You have one table. You combo boxes do not need to be "connected" in any way.

I am very confused on this...
Jul 25 '19 #10
I appreciate your patience. Your response seems to indicate I'm missing something obvious here. Maybe I'm over complicating what should be a very simple solution.

Please allow try to explain what I'm trying to achieve once more.

At the moment I have one table - tblAll

This has columns titled ID (PK), PackageNo, PackageDescription, Activity, ProductivityRateLow, ProductivityRateHigh, Unit, TimePeriod, Notes, Source, LeadTimeLow, LeadTimeHigh.

My form contains combo boxes cboPackageNumber and cboActivity

And text boxes txtRateHigh, txtRateLow, txtUnit, txtTimePeriod, txtSource, txtNotes, txtMax, txtMin

I have added buttons cmdSave, cmdAdd, cmdClose

The user first selects the Package Number from cboPackageNumber, then selects the Activity from cboActivity, from a list of activities associated with that package. Once the Activity is selected the rest of the text boxes are populated with the data for that activity.

This all works great to look up records from the table. However, I would like users to be able to save changes to the records in the form back to tblAll. I also want to be able to add new records. At the moment if any information is changed in the text box fields on the form it is not saved back to the table.

My VB code is currently this:-

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Private Saved As Boolean
  3. Option Explicit
  4.  
  5.  
  6. Private Sub cboActivity_AfterUpdate()
  7.  
  8. Me.txtRateHigh = [cboActivity].Column(5)
  9. Me.txtRateLow = [cboActivity].Column(4)
  10. Me.txtUnit = [cboActivity].Column(6)
  11. Me.txtTimePeriod = [cboActivity].Column(7)
  12. Me.txtSource = [cboActivity].Column(9)
  13. Me.txtNotes = [cboActivity].Column(8)
  14. Me.txtMax = [cboActivity].Column(11)
  15. Me.txtMin = [cboActivity].Column(10)
  16.  
  17.  
  18. End Sub
  19.  
  20.  
  21. Private Sub cboPackageNumber_AfterUpdate()
  22.  
  23. Dim strSql As String
  24. strSql = "SELECT o.ID, o.PackageNo, o.PackageDescription, o.Activity, o.ProductivityRateLow, o.ProductivityRateHigh, o.Unit, o.TimePeriod, o.Notes, o.Source, o.LeadTimeLow,  o.LeadTimeHigh " & vbCrLf & _
  25. "FROM tblALL AS o" & vbCrLf & _
  26. "WHERE o.PackageNo = '" & cboPackageNumber.Value & "'" & vbCrLf & _
  27. "ORDER BY o.PackageNo;"
  28. Debug.Print strSql
  29. cboActivity.RowSource = strSql
  30.  
  31. If cboPackageNumber > 0 Then
  32.  
  33.     cboActivity.Visible = True
  34.     Me.cboActivity.Requery
  35.  
  36.  
  37. Else
  38.  
  39.     cboActivity.Enabled = False
  40.  
  41. End If
  42. End Sub
  43.  
  44. Private Sub cmdSave_Click()
  45.  
  46.    Saved = True
  47.    DoCmd.RunCommand (acCmdSaveRecord)
  48.    Me.cmdSave.Enabled = False
  49.    Saved = False
  50.  
  51. End Sub
  52.  
  53. Private Sub Form_BeforeUpdate(Cancel As Integer)
  54.  
  55. Dim Response As Integer
  56. If Saved = False Then
  57.     Response = MsgBox("Do you want to save the changes on this record?", vbYesNo, "Save Changes?")
  58.     If Response = vbNo Then
  59.        Me.Undo
  60.     End If
  61.     Me.cmdSave.Enabled = False
  62. End If
  63. End Sub
  64.  
  65.  
  66.  
  67. Private Sub cmdAdd_Click()
  68.  
  69. On Error GoTo cmdAdd_Click_Err
  70.  
  71.     On Error Resume Next
  72.     DoCmd.GoToRecord , "", acNewRec
  73.     If (MacroError <> 0) Then
  74.         Beep
  75.         MsgBox MacroError.Description, vbOKOnly, ""
  76.     End If
  77.  
  78.  
  79. cmdAdd_Click_Exit:
  80.     Exit Sub
  81.  
  82. cmdAdd_Click_Err:
  83.     MsgBox Error$
  84.     Resume cmdAdd_Click_Exit
  85.  
  86. End Sub
  87.  
  88.  
  89. Private Sub Form_Dirty(Cancel As Integer)
  90.  
  91. Me.cmdSave.Enabled = True
  92. End Sub
The code for the cmdSave I copied from another source, which seemed to be what I was trying to achieve with the save function.

Sorry to dump all my code here again, I'm hoping this makes it easier to understand where I am and where I'm going wrong.
Jul 26 '19 #11
Hi twinnyfo,

There's something I should have explained, which is impossible to understand without seeing the actual table with the data. The reason I have 2 combo boxes and needed them to be linked is because of package numbers. The first combo box contains the list of package numbers of which there are around 30 no. This list of package numbers is fixed and will not change. Each record (Activity) is assigned to one of these package numbers.

The way I need the form to work is for the first combo box to show the list of 30 package numbers. Once a package is selected the second combo box will only show the activities assigned to that package number.

Can this be done with one form and still allows edits to the records?

Would it be better to split the package numbers and package description columns into a separate table as this list will never change?
Jul 27 '19 #12
twinnyfo
3,653 Expert Mod 2GB
Yes - you need to use a bound form. Filter the form by each combo box in sequence. With a bound form, any changes to the record are saved to the table. You can move to a new record to add records. Get to the bound form first, as this is the first, most important step.

Yes, I do think you are highly over complexifying in this.
Jul 28 '19 #13
NeoPa
32,556 Expert Mod 16PB
AdmiralN:
Can this be done with one form and still allows edits to the records?
I won't go into the whole thread but this stood out as a straightforward question. There are articles around that show how to do this (Cascaded Form Filtering).
Aug 18 '19 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: deko | last post by:
I'm trying to set up a "preferences form" where users can choose from a few different pre-defined colors. The color numbers and form names are saved in tblColors. The below code changes the form...
2
by: Tolu | last post by:
Hello I am trying to save information from one form to two tables. I have a table for Student info and Transcript line. I have a form that list all the classes (using text boxes) a student is...
4
by: Sangeetha. | last post by:
I have a datagrid with just one row. When I edit the contents of the datagrid and click on Save button (somewhere else in the form), the changes are lost. However, if I click TAB from the editable...
11
by: Kevin | last post by:
I've been searching forever for examples of saving data changes in a DataGridView. There's all kinds of examples, but none really show how to save changes. Someone please help me. I have a...
2
by: ClearCut | last post by:
I have written a program in VB6 that opens an existing Word document and adds some text to the top of the document before printing it. Now I want to close the document without saving the changes. ...
4
by: ARC | last post by:
Hello all, I didn't use to have this problem in Access 97, but in 2007 (and maybe other versions of access after 97), if you have a form that has a subform, and you click the close button, you...
1
by: Allie | last post by:
Hi, all. This might be a silly question... but I am very new to programming in SQL so please bear with me :) So. I'm using MS SQL Server 2005 Management Studio Express. I have a table that...
0
NeoPa
by: NeoPa | last post by:
Introduction : This article relates to the long-standing (Since at least Access 2.0.) problem whereby a Form, used within a Subform of another (main) Form, will have any temporary and transient...
2
by: moonrb | last post by:
Hi. Can any one tell me---- how to prevent saving data on form in access 2002 or 2003 when user clicks close button of the window or during abnormal shutdown ?
7
Seth Schrock
by: Seth Schrock | last post by:
I know that I can do this using a temp table, but I'm hoping for another solution that would be easier. I want to be able to open a form (in continuous view) with the current data and play with the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.