K
Karen Hagerman
I have a main form with a subform that is a continuous view. On the subform the 'AllowEdits' property is set to 'Yes' but the 'New' navigation button is never active. Any ideas?
Karen
Karen
I have a main form with a subform that is a continuous view. On the subform the 'AllowEdits' property is set to 'Yes' but the 'New' navigation button is never active. Any ideas?
Karen
Karen Hagerman said:I have a main form with a subform that is a continuous view. On the
subform the 'AllowEdits' property is set to 'Yes' but the 'New'
navigation button is never active. Any ideas?
Karen said:John and Dirk,
Thanks, that was it, I based it on a query. I based the form on a
query instead of a table because I can't seem to use filter a form to
open only one record from a table based on the table's primary key
for that record. I have tried
------------------------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "TestContactForm"
stLinkCriteria = "[ContactID]=" & 6
DoCmd.OpenForm stDocName, , , stLinkCriteria
-----------------------------------------------------------------AND
I'VE TRIED
setting the form's record source to the table and putting
[ContactID]=6 in the Filter property. Allow Filters is 'Yes'
I have been working for hours and this should not be hard at all,
what am I'm doing wrong?
Should I repost this as a separate question or do you have any advice?
Dirk Goldgar said:Karen said:John and Dirk,
Thanks, that was it, I based it on a query. I based the form on a
query instead of a table because I can't seem to use filter a form to
open only one record from a table based on the table's primary key
for that record. I have tried
------------------------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "TestContactForm"
stLinkCriteria = "[ContactID]=" & 6
DoCmd.OpenForm stDocName, , , stLinkCriteria
-----------------------------------------------------------------AND
I'VE TRIED
setting the form's record source to the table and putting
[ContactID]=6 in the Filter property. Allow Filters is 'Yes'
I have been working for hours and this should not be hard at all,
what am I'm doing wrong?
Should I repost this as a separate question or do you have any advice?
It's not being based on a query per se, it's that this particular query
is apparently not updatable. I don't see anything wrong with the code
you posted above, provided of course that ContactID is a numeric field
in the form's recordsource -- not a text field. If there is no record
with ContactID = 6, you'll get a blank form, of course.
What happened when you tried the above code? Did you see an error
message? What do you see if you open the form without the criterion?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Karen said:Hi Dirk,
Again, thanks for looking at this. I don't get an error message, the
filter is just ignored. If I specify an ID that only has one match,
I see all of the items in the table. Any ideas?
Karen said:Dirk,
Here it is. The TestContactTable
The form properties
The result
I have to go earn some money now but if you see anything, don't
hesitate to educate me!
Karen said:Dirk,
OK, I won't do that again.
In order to troubleshoot this problem I had gone back to the form
that I am using as a subform on another form.
When I type DoCmd.OpenForm "TestContactTable", , ,"ContactID=1" in the
immediate window, it does open and it is filtered. When I open the
form by itself, it does not open filtered even though the filter on
the form's property sheet is [ContactID]=1.
When it is a subform this is the code that opens it
(in this case it
is filtered but it is because it is based on a query--back to the
original problem, when it is based on a query I can't get the subform
to allow additions. That is why I wanted to based the subform on the
table and filter it)
SELECT DISTINCT TestCompanyContactLinkTable.ccCompanyID,
TestCompanyContactLinkTable.ccContactID, TestCompanyMain.CompanyName,
TestContactTable.*
FROM TestContactTable INNER JOIN (TestCompanyMain INNER JOIN
TestCompanyContactLinkTable ON TestCompanyMain.CompanyID =
TestCompanyContactLinkTable.ccCompanyID) ON
TestContactTable.ContactID = TestCompanyContactLinkTable.ccContactID
WHERE
(((TestCompanyContactLinkTable.ccCompanyID)=[Forms]![TestTestBusinessTab
]![C
ompanyID]));
Basically there is a table that has Companies and a table that has
Contacts. There is also a table that lists CompanyID's with any
associated ContactID's. The reason for the third 'index' table was
because contacts can be associated with more than one company at the
same time.
I think this is probably starting to get way too complicated so if
you don't see something obvious, you can let it go.
It is a mystery.
OK, that I did not know. When I can't get something to work I go back toIf "when I open the form by itself" means "when I open it from the
database window", then that is as it should be. Access stored the last
filter applied in the form's Filter property, but it doesn't apply it
until you explicitly tell it to, either via the user interface (e.g., by
clicking the Apply Filter button) or by code (e.g.,
Forms!TestContactTable.FilterOn = True).
Now you are confusing me. You don't use code to open a subform; it
opens automatically as part of the opening of its parent form.
It really is a subform. It is a tabbed form, the first tab has fieldstalking about a real subform here? That is, a form displayed in a
subform control on a parent form?
Got it, I really did know that the SQL was the recordsource but myAnd the above isn't code that opens a form; it's just the SQL of what I
gather is the recordsource of the form. I don't understand what you
mean when you say, "When it is a subform this is the code that opens
it".
Yes, that is exactly it. The contacts do display correctly, i.e. the firstLight is beginning to dawn, though. Forgive me if I'm jumping to
conclusions, but I have the impression that you aren't too clear on how
subforms work. Is that correct, or do you think I'm just
misinterpreting your words? Suppose we step back a bit, and you tell me
in broader terms how you want your forms to work. Are you trying to set
up a main form based on TestCompanyMain, with a subform that displays
all the contacts for the company that is current on the main form?
Karen
Karen said:Dirk,
OK, that I did not know. When I can't get something to work I go
back to the individual components to sort out the problem. Thanks so
much for that bit of info, who would have thunk!
I knew that, I just got confused when you asked for the code that
opened the form and when you mentioned the 'where' condition I
thought you meant the recordsource.
Are we
It really is a subform. It is a tabbed form, the first tab has fields
related directly to the tabbed form's recordsource and I dragged the
'contacts' form to the second tab.
Yes, that is exactly it. The contacts do display correctly, i.e. the
first tab is the info related to a company and the contacts tab only
has the contacts associated with that company. I was frustrated
because I'd like to add new contacts from the contacts tab but I
can't get the asterisk (*) 'new' navigator button to be active. At
this point I think I'll just have to use a command button to open a
separate form to add new contacts.
Again, thanks for the patience. I'm still a very green Access person
but it's so much fun it's hard to stop.
Karen said:OK, I take it back. This is not fun. I used your suggested
recordsource and it works like a champ. I set it as the recordsource
of the contacts subform. I set the Link Master Fields property of
the subform control to CompanyID and the Link Child field to
ccCompanyID. I doublechecked that the main form allowed additions
and edits as well as the subform.
Everything works, the data looks good BUT the 'new' navigation button
is not active. AARGH!
John Viescas said:Ummm. Did I see a DISTINCT keyword in the SQL earlier in the thread?
That would make the query, and therefore the form, not updatable.
Karen said:John and Dirk,
Thank you from the bottom of my heart, I can fly again.
John, that was it, I removed the 'Distinct' from the SQL statement
and left everything else as suggested by Dirk and voila!, it works.
recommended SQL. said:Besides books (John, I see you have a few under your belt) and just
diving into projects and, of course, the newsgroups; do either of you
have other suggestions I could use to really learn Access?