Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access datasheet and hide rows

Posted on 2012-12-28
8
Medium Priority
?
746 Views
Last Modified: 2012-12-28
I have a form that's in datasheet view
It has a subform also in datasheet view

The subform and parent form both have a column txtMyId

What I want to do is if Me.txtMyId <> Me.Parent.txtMyId then

Hide entire data row if possible


I tried testing with the following code and an extra unbound column to update
But it comes back with everything "Matches" which I KNOW isn't correct

Do I need some kind of "For Each?"

I can do that in .Net easily

    If Me.txtMyId = Me.Parent.txtMyId Then
        Me.txt2 = "Matches"
    Else
        Me.txt2 = "No Match"
    End If
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38727073
<What I want to do is if Me.txtMyId <> Me.Parent.txtMyId then
Hide entire data row if possible>

Why not just filter for this?:

Make the recordsource for the form:
SELECT....
FROM Yourtable
WHERE MyId <> Forms!YourForm!MyID

...or something similar

JeffCoachman
0
 

Author Comment

by:lrbrister
ID: 38727100
boag2000
This subform datasource is a view from SQL Server and set in the properties box.

I want to do this in VBA if at all possible...

The actual <> will look like this...

If Nz(Me.txtMyId,Me.Parent.txtMyId ) <> Me.Parent.txtMyId
...
This will allow nulls and whatever = the Parent

How do I set this in VBA when the datasource is a straight properties view?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38727216
With the addition of the NZ(), it is still not clear what you need here, ...

If the Recordsource is set, and cannot be changed, ...you can set the Filter Property of the subform:
MyID<>Forms![frmParent]![MyID]
(and probably set the FilterOnLoad Property to: Yes)

I mean, you can filter dynamically with VBA, but I don't a reason to go through all the extra work, if you can just filter.

Can you post a simple sample of this database?, it is confusing that you seem to want to filter on your "Linking" field.

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide any hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38727231
Here is the sample DB I worked up and it sets the filter Prop of the subform.
(Open the database and examine the raw data first)

It seems to do what you asked:
    "if Me.txtMyId <> Me.Parent.txtMyId then Hide entire data row if possible"
Database5.accdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38727370
I may have crossed to logic, ...but I am sure you can figure out what needs to be done to fix the syntax...
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 38727431
Yeah, I think the filter you may have wanted is actually:
MyID=Forms![frmParent]![MyID]
0
 

Author Closing Comment

by:lrbrister
ID: 38727467
Example set me straight.

Watch for a new question
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38727486
;-)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question