473,385 Members | 1,267 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,385 software developers and data experts.

Subform showing records before choice made on Mainform

18
I’m using Access 2003 on Windows XP.

I have a Mainform (Staff Entry) which displays an unbound combo box named ChooseStaff. The Row Source for this combo box is a SELECT of the UserIDs and Staffer Names from a table (Staffers) which contains staffers’ names and other info.

When the user actually selects a Staffer Name from the dropdown combo box, the VBA routines for the combo box’s On Enter and After Update events take care of finding and displaying the appropriate records in the Subform (Report Entry) from a table (Status Reports) which contains reporting information – where UserID in Staffers table matches UserID in Status Reports table. This works fine.

The problem arises when the Mainform is first displayed. The combo box is shown as empty but the Subform displays the records for the first UserID in the underlying table Staffers. If the user goes directly to the Subform and starts entering/modifying data, the Status Report records for the staffer that matches the first UserID are the ones that get modified, even though the user hasn’t even selected a staffer from the combo box.

What I want to happen when first entering the Mainform is to show a blank/inaccessible Subform until the user has selected a staffer from the combo box and the VBA routines have displayed the matching info in the Subform (i.e., force the user to make a selection first). I’m guessing some code should be written for the Mainform’s On Open event, but I’m not very experienced in Access and am at a loss.

Appreciate any help with this. Many thanks.

Janice
Aug 6 '08 #1
5 2597
NeoPa
32,556 Expert Mod 16PB
I would consider setting the subform's .Enabled property to False in the design, and setting it to True whenever the operator actually selects an item.

Does this sound like it may be a suitable solution?
Aug 6 '08 #2
JHite
18
I added lines 11, 23 and 28 based on your suggestion (see code below) but that did not change a thing. The subform is still "active" and shows info for the first UserID without the user having entered/selected anything in the combobox.

name of combobox is ChooseStaff
name of main form is frmStaffEntry
name of subform is frmStatusReports

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3.  
  4. Private Sub ChooseStaff_AfterUpdate()
  5.  ' Find the record that matches the control.
  6.     Dim rs As Recordset
  7.     Set rs = Me.RecordsetClone
  8.     rs.FindFirst "[UserID] = " & Str(Nz(Me![ChooseStaff], 0))
  9.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  10.     rs.Close
  11.     Set rs = Nothing
  12.     Forms!frmStaffEntry!frmStatusReports.Enabled = True
  13.     With Me!frmStatusReports.Form
  14.        .RecordSource = "qrySRSortDate"
  15.        !SortOption = 1
  16.     End With
  17. End Sub
  18.  
  19. Private Sub ChooseStaff_Enter()
  20. If Me.Dirty Then
  21.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  22.   End If
  23. Me![ChooseStaff].Requery
  24. Forms!frmStaffEntry!frmStatusReports.Enabled = True
  25. Forms!frmStaffEntry.Form!frmStatusReports.Requery
  26. End Sub
  27.  
  28. Private Sub Form_Load()
  29. Forms.frmStaffEntry!frmStatusReports.Enabled = False
  30. End Sub
  31.  
  32.  
I also tried the same code on Form_Open and got the same results.

Do you have any other suggestions or did I misinterpret what you thought might work???

Thanks again for your help.

Janice
Aug 12 '08 #3
NeoPa
32,556 Expert Mod 16PB
Firstly, I think you probably have a problem with the idea of a SubForm control. Please read Referring to Items on a Sub-Form for a better understanding (Saves me repeating it all in here ;)).

Also, I wonder if you changed the property first in the design of the form?

You will also need to reset it in the form's Current event (Private Sub Form_Current()). If ChooseStaff is a bound ComboBox then this will need to be reset depending on the data in the underlying field.

Please feel free to ask questions relating to this after you've read through it.
Aug 12 '08 #4
JHite
18
Firstly, I think you probably have a problem with the idea of a SubForm control. Please read Referring to Items on a Sub-Form for a better understanding (Saves me repeating it all in here ;)).

Also, I wonder if you changed the property first in the design of the form?

You will also need to reset it in the form's Current event (Private Sub Form_Current()). If ChooseStaff is a bound ComboBox then this will need to be reset depending on the data in the underlying field.

Please feel free to ask questions relating to this after you've read through it.
Sorry it's taken me so long to respond. I had to turn my attention to another issue and have just now come back to working on this Access database.

I now understand what you meant in the first place. When I set the subform's Enabled property to No in the design, it disabled the ability to access the subform but still showed the subform information for the first person (UserID = 1). So I used the subform's Visible property instead - setting it to No in the design and then setting it to True in the combobox's after_update.

Works great! Thanks again for your help.

Janice
Oct 2 '08 #5
NeoPa
32,556 Expert Mod 16PB
It sounds like you came up with a better solution then :)

Well done Janice.

PS. No worries about the delay. We have plenty to keep us busy ;)
Oct 3 '08 #6

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

Similar topics

0
by: P Mitchell | last post by:
Hello I would like someone to be able to help with the updating of data in a lookup list in a subform. In short, is their a VB instruction that is the equivalent of performing the action of...
1
by: Greatmaze | last post by:
Hi All, I want to update a column in my Users table through a subform. I have made a mainform where you can choose a Department (from Department table), then a subform pops-up showing the users...
0
by: misscrf | last post by:
I have this normalized database, and I don't understand why setting up the forms is so hard for me. I have the main candidate entry form. This is to enter in candidates who apply for a job. I...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
1
by: MLH | last post by:
I have frmVehicleEntryForm and on it is frmAddnlOwnrListSubForm. The subform is unbound and lists records in a table, allowing the user to change values in CheckMark controls on the subform as...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
18
by: Robert Jacobs | last post by:
Please advise... I currently have a Mainform (Customers) and a Subform (Service Requests) with a one to many relationship (one customer, many service requests) with a CustomerID that is unique...
2
by: mnms | last post by:
Hi, I'm trying to create an "overview" form. And I haven't been able to figure out how to get Access to do what I want yet. Basicly what I want, is to populate a subform based on a field...
5
by: samdev | last post by:
I have created two combo boxes in a subform.... For example 1. Combo Box State 2. Combo Box City 3. When a state from the Combo Box State is selected, the City combo box updates to reflect...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.