473,385 Members | 1,341 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 Problems (Access 2000 format)

truthlover
107 100+
I have a problem that's difficult to explain, so please be patient.

The database is in 2000 format, though I'm doing most of the designing in 2007 (saved as 2000 format, of course)

I have a continuous form frmEditConstructionLog with an unbound combobox that filters the results to the desired project number. This works fine.

I need to add the option of choosing multiple Crew Members, and this is where I'm stuck...

I cant use a subform because the form is in Continuous Form view (which is necessary). But all attempts to launch a form (popup) that will automatically insert the contents of the SurveyCrewLogID field into the subform fkSurveyCrewLogID (*and* filter the subform to display only those IDs) have failed.

I have tried several methods. Only two have had any promise, but both had problems I was unable to solve...

First was a command button that would open a simple datasheet view subform (subfrmAddCrewTeamMember) with the SurveyCrewLogID field and AdditionalCrew fields. Problem was it will insert the SurveyCrewLogID into the first record from the main form, but if someone has to enter more than one person, the SurveyCrewLogID field remains empty. I need that field automatically populated and dont know how to do that.

The second method (the only other one that I had any success at) was a pop up form that used the subfrmAddCrewTeamMember as a subform. The problem I had with that is it only worked in Add mode (which didnt allow the user to see if there were any other names entered) and if someone clicked on it and got out without entering a name, it either entered a blank value or gave an error message (depending on whether I had made the field required). When I coded it to open in Edit mode, it didnt filter the subforms to the desired SurveyCrewLogID field.

I will post the code for both methods below. Hopefully, someone will be able to show me what I did wrong, or what I can do to correct the problem.

(I actually prefer the second method since it gives the user an overview of the record they're updating)

First Method:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddCrew_Click()
  2. On Error GoTo Err_cmdAddCrew_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "subfrm_SurveyCrewTeams"
  8.  
  9.     stLinkCriteria = "[fkSurveyCrewLogID]=" & Me![SurveyCrewLogID]
  10.     DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria, acFormEdit
  11.  
  12.     Forms!subfrm_SurveyCrewTeams![fkSurveyCrewLogID] = Me![SurveyCrewLogID]
  13.  
  14. Exit_cmdAddCrew_Click:
  15.     Exit Sub
  16.  
  17. Err_cmdAddCrew_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_cmdAddCrew_Click
  20.  
  21. End Sub
Second Method:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddCrewMembers_Click()
  2.  
  3. DoCmd.RunCommand acCmdSaveRecord
  4.  
  5. On Error GoTo Err_cmdAddCrewMembers_Click
  6.  
  7.     Dim stDocName As String
  8.     Dim stLinkCriteria As String
  9.  
  10.     stDocName = "frm_AddCrewTeamMembers"
  11.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  12.  
  13. Exit_cmdAddCrewMembers_Click:
  14.     Exit Sub
  15.  
  16. Err_cmdAddCrewMembers_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_cmdAddCrewMembers_Click
  19.  
  20. End Sub
If anyone is so kind as to help, please be patient. I know Access, but not VBA so you may need to explain with lots of details.

Thanks so much!
Nov 24 '08 #1
12 3098
ChipR
1,287 Expert 1GB
I'll give you another option here. This is an example straight from my application with errorhandling removed for brevity. It uses the OpenArgs argument of the OpenForm.

--View Projects-- form
Private Sub EditProjectButton_Click()
If ProjectNumberCombo.ListIndex < 0 Then
ProjectNumberCombo = ProjectNumberCombo.Column(0, _
CurrentPage.Caption - 1)
End If
DoCmd.OpenForm "Edit Project", , , , , , ProjectNumberCombo
End Sub

--Edit Project-- form
Private Sub Form_Open(Cancel As Integer)
Dim strProjectNumber As String
If IsNull(Me.OpenArgs) Then
MsgBox "No project specified."
DoCmd.Close acForm, "Edit Project"
Exit Sub
Else
strProjectNumber = Me.OpenArgs
End If

'only 1 record should be available to the form
Me.Filter = "ARDECProjectNumber = """ & strProjectNumber & """"
Me.FilterOn = True

'initialize fields
...

Also, you can string together OpenArgs like
DoCmd.OpenForm "Edit Project", , , , , , string1 & " , " & string2 & "," string3

then in Form_Open

dim strArgs() as String
strArgs = Split(Me.OpenArgs, ",")
Box1 = strArgs(0)
Box2 = strArgs(1)
Box3 = strArgs(2)

Hope that helps.
Nov 24 '08 #2
truthlover
107 100+
Hi Chip

Sounds like that could work. Only problem is I'm really not good with VBA and though it seems simple enough, I have no idea where to put the code.

Can you help?

Thanks!
Nov 24 '08 #3
ChipR
1,287 Expert 1GB
What exactly do you have and want to have in the new form you pop up?
Nov 24 '08 #4
truthlover
107 100+
@ChipR
I'm putting together a response. Hope to have it up soon. Thanks!
Nov 25 '08 #5
truthlover
107 100+
@ChipR
The best way for me to explain it is to show you the application. (I only included the necessary forms, tables and queries). This will also allow you to see all the corresponding code.

I tried to upload the file, but it said it exceeded the size allowed by the size of the file, not even one MB. (??) So I uploaded it to my site. You can access it here.

Anyway, the file will open to the main form (for purpose of this post). The "Additional Crew" button is the first method I referred to. That one's self explanatory. I want the pop up to filter and display only the corresponding SurveyCrewLogID, and that each time the user advances, that SurveyCrewLogID is automatically generated.

The "Add Crew Member" button is the second, and preferred method. It's not as obvious what the problem is at first, until you click the button for several different SurveyCrewLogID's. You'll see when you do, that the SurveyCrewLogID and Crew Member follows you from one record to the next. (That's what happens when I have the form open in Edit mode).

If, however, I have the form open in Add mode, it works properly, but the user can't use the button to see who's already been entered.

What I need to happen is that the subform be properly filtered to only display entries to the cooresponding SurveyCrewLogID. If there are no entries, it should show only the field with the * allowing the user to enter a name. If there are entries, it should show that name (with matching SurveyCrewLogID and the field with the * for entering an additional crew memeber.

I hope this will explain what I'm after.

Thanks so much for your time!
Nov 25 '08 #6
ChipR
1,287 Expert 1GB
Sorry, but I won't be able to look at this until tomorrow.
Nov 25 '08 #7
ChipR
1,287 Expert 1GB
Your query is joining on the tbl_QuerySurveyTeams and coming up with very few records. First, change your query and get rid of the tbl_QuerySurveyTeams because that's handled by the subform. Add the tbl_SurveyCrewLog.SurveyCrewLogID field to the query. That's the field which you'll filter the form on and use as the master field to the subform. The child field is the fkSurveyCrewLogID.

So in your frm_EditConstructionLog:cmdAddCrewMember_Click() do
DoCmd.OpenForm "frm_SurveyCrewTeams", , , "SurveyCrewLogID = " _
& SurveyCrewLogID

Then on the subfrm_SurveyCrewTeams change the Link Master Fields to SurveyCrewLogID and remove that filter on the data tab.

Should work.
Nov 26 '08 #8
truthlover
107 100+
Chip,

I did see this, but it's a little hard for me to decipher (Sorry. I tried to warn you I might need things really spelled out).

I've got some things happening at work that I need to take care of first, but I'm hoping some time next week to tackle this again.

Thanks!

@ChipR
Dec 4 '08 #9
truthlover
107 100+
Hi Chip

I hope you're still around...

I got the first part, but I dont understand what you mean by
Then on the subfrm_SurveyCrewTeams change the Link Master Fields to SurveyCrewLogID and remove that filter on the data tab.
Can you explain a little further?

Thanks for your help and your patience!!
Dec 9 '08 #10
truthlover
107 100+
Never mind, I think I got it working.

Thanks!!

@truthlover
Dec 9 '08 #11
truthlover
107 100+
I was wrong, I thought it was working, but I'm still having problems. As soon as I can, I'll post the problems I'm still having.

Thanks!

@truthlover
Dec 11 '08 #12
truthlover
107 100+
Just an update ... the problem hasnt been resolved, but the people who are using it decided they wanted to use a different process anyway, so the form is no longer needed.

Thanks for your help.

Merry Christmas everyone!


@truthlover
Dec 18 '08 #13

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

Similar topics

4
by: David | last post by:
Hi, I want to work with Access 2002. I will need to be able to distribute my application to users that may still have access 2000 on their computers. I know access 2002 has a function that...
15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
4
by: wayne dooley | last post by:
This should be easy. I have 2 tables - CUST and SUBS, which have a 1 to many relationship. I created a form to show fields from CUST and a subform to show those in SUBS. The 2 tables are related...
2
by: Tom van Stiphout | last post by:
Hi All, This one has me stumped. I hope someone else has seen this behavior and knows what's going on. I'm using Access 2003 ADP on Windows XP, database in 2002/2003 format, with SQL Server 2000....
1
by: Marcin | last post by:
Im using MS Access 2000. i have a main form and ona subform that is scrolled vertically. unfortunately i use mouse scroll to scroll this subform. I appreciate your help
4
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within the form is a subform that is also, through a Q,...
4
by: Steve_s | last post by:
Hi I am having problems totalling a particular field in a subform.I am using Access 2003. The subform is based on a query which selects records with various financial information. I have 5 text...
1
Andrew Thackray
by: Andrew Thackray | last post by:
Hi Can anyone help. I have an obscure problem with an unbound sub form on my main form. Both forms are unbound as my data structure is too complex for a sinngle binding. In the main form I have...
1
by: saundap | last post by:
Hi, Access 2000, Windows 2000 Professional I have a form I've developed that is designed for those not familiar with access and its query tool. WIthin a subform in the form there is presented...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.