UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Viewing Tables, Access 2010    
 
   
RockManFree
post Apr 30 2019, 05:46 PM
Post#1



Posts: 4
Joined: 30-April 19



I want to use MS Access 2010 VBA to build an event that does two things:
1. On a form button click, open two different Tables in the db object viewer window.
2. Position the tables side-by-side so I can see each table.

Action #1 is quite easy, but for the life of me I can't figure out how to do #2 using VBA. (I am a bit of a newbee).

Now, with all do respect, please don't ask me "why on earth would you want to do that", because I just do. smile.gif

Thank you for any ideas on how to accomplish this. I've tried searching the forums, but I can't even find the correct search terms because nothing even remotely related to this is being found.
Go to the top of the page
 
WildBird
post Apr 30 2019, 05:54 PM
Post#2


UtterAccess VIP
Posts: 3,578
Joined: 19-August 03
From: Auckland, Little Australia


Have a form with 2 lists in it, next to one another. Data source is the tables. Make this the start up form.

--------------------
Beer, natures brain defragging tool.
Go to the top of the page
 
RJD
post Apr 30 2019, 06:07 PM
Post#3


UtterAccess VIP
Posts: 9,733
Joined: 25-October 10
From: Gulf South USA


welcome2UA.gif

First, I suggest you not open the tables, but put the tables through queries as the record source for forms, and open those forms.
Second, use the Overlapping Windows option and open and place the forms where you want them, and save them.

See the demo attached.

Or you could make the two forms subforms on a main form ...

HTH
Joe
Attached File(s)
Attached File  OpenTwoTables.zip ( 22.55K )Number of downloads: 2
 

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
GroverParkGeorge
post Apr 30 2019, 07:07 PM
Post#4


UA Admin
Posts: 35,307
Joined: 20-June 02
From: Newcastle, WA


As a general rule, we tend to avoid--and even discourage--editing data directly in tables.So a task like this DOES raise questions.

For example, are you doing this for a data clean-up task? Or a data comparison task? Will it be done repeatedly? Will it always involve the same two tables? Will end users be asked to do this? Or is it for maintenance/management tasks?

If this is a one-time clean-up, perhaps the use of elaborate forms would be overkill, but even if it is a one-time task, the control a form gives you argues for going that direction anyway.

And finally, how many records are in these tables? 10s, 100s, 1,000S? It might make sense to invest a little extra time in getting this all set up for easy use if the number of records is on the higher side, but less sense for a handful.

All in all, the recommendation depends, in part, on the circumstances, i.e. the business rules that apply.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
RockManFree
post May 1 2019, 10:51 AM
Post#5



Posts: 4
Joined: 30-April 19



lol - Thanks guys -- I knew I would get these kinds of responses so I tried to head them off with my "why on earth would you want to do that, because I just do" line!

BUT - you all make valid questions, so I'll try to be as succinct as I can:
1. I want to learn more about controlling the Access container, so I'd like to learn how to do exactly what I asked.
2. I do NOT want to display the tables in forms or queries -- I know how to do that.
3. This would not be for user functions available to anyone but me in developer mode. (Lazy shortcut as it were)
4. Yes, they will be large tables with thousands of rows and about 10 fields max.
5. I will open Different tables from time to time (my "menu" form will let me select which ones - I know how to do all this)
6. Since I will also be manipulating tables and views as I am developing, there will NEVER be a standard table(s) location in the viewport, so I don't think it would be useful to set up the display (table view locations) then save their positions. I need to be able to assure the tables open to view right where I tell them to! (I just don't know how to do this)

If this request is too involved or too technical for this forum, I'd appreciate some ideas that at least I can go try to research - even if it does attack everyone's sensibilities! smile.gif
To quote myself: "Sometimes no reason is the perfect reason!" lol Thanks again for listening!
Go to the top of the page
 
GroverParkGeorge
post May 1 2019, 11:43 AM
Post#6


UA Admin
Posts: 35,307
Joined: 20-June 02
From: Newcastle, WA


Perhaps the reluctance to get onboard has less to do with "sensibilities" and more to do with "practical" considerations. As in, investing time in a project like this may be worthwhile for your own purposes. Given the limited practicality (from my point of view), it's not something I'd invested time in investigating.

That's particularly true with large recordsets. If I had to compare, side by side, two tables with 3,000 records each, I doubt I'd start with datasheet view of the entire tables.

However, re-reading your original question, I wonder if you are interested in tables in datasheet view. "Position the tables side-by-side so I can see each table."

I could see opening them in design view that way, though.


--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
ADezii
post May 1 2019, 01:39 PM
Post#7



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
I suggest you not open the tables, but put the tables through queries as the record source for forms, and open those forms.

  1. First of all, I would follow the path that RJD indicated in Post# 3 (quoted above).
  2. You can precisely position all your Forms exactly where you want them and save these critical measurements (Left, Top, Width, Height) in either Pixels or Twips.
  3. You can re-position these Forms at any time and re-register their new locations in the Close() Event of each Form.
  4. Now, whenever these Forms are opened, they will revert to their last saved location (when they were closed).
  5. If you do not wish to automatically save their locations and dimensions, you can do this manually.
  6. Is this doable, Yes.
  7. Is it easy, Nope. Requires intimate knowledge of the API and classes.
Go to the top of the page
 
RockManFree
post May 1 2019, 01:59 PM
Post#8



Posts: 4
Joined: 30-April 19



Thanks Guys.

It is obvious to me that I am not explaining myself very well. Sorry about that.
For the moment, let's forget about any VBA automation, forget about Forms, forget about user use cases.
Let me just explain what I am manually doing (also forget about "Why?" for a moment)

Step 1: Open MS Access (In my case from Office 10)
Step 2: Open "Table1" in datasheet view. (say it has 2500 rows with 5 columns)
Step 3: With my mouse, grab a corner of the table1 and drag it to display its width in one-half of the available window.
Step 4: Open "Table2" in datasheet view. (say it has 1500 rows with 7 columns)
Step 5: With my mouse, grab a corner of the table2 and drag it to display its width in the remaining one-half of the available window. (then drag it side by side)
Result: I have two tables displaying in datasheet view side-by-side. (No Forms open at all - just the 2 tables)

OK. That is all I want to do -- so now how do I do that in VBA?

If this would be very time consuming to explain, could you point me to a source somewhere that I can figure out how to do this? Thanks!
Go to the top of the page
 
ADezii
post May 1 2019, 02:36 PM
Post#9



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


Open the Tables, each in turn, then position and re-size using the MoveSize() Method of the DoCmd Object. If necessary, I can give you an example of how this can be done.
Go to the top of the page
 
tina t
post May 1 2019, 03:10 PM
Post#10



Posts: 5,982
Joined: 11-November 10
From: SoCal, USA


i googled "ms access move resize" and got a lot of hits. a quick look suggested that you start by taking a look at the following link, as

https://support.office.com/en-us/article/mo...2b-0e03b52205d2

hth
tina
This post has been edited by tina t: May 1 2019, 03:11 PM

--------------------
"the wheel never stops turning"
Go to the top of the page
 
RockManFree
post May 1 2019, 04:28 PM
Post#11



Posts: 4
Joined: 30-April 19



Thank you ADezii. It is embarrassing how simple it was. That MoveSize clue was exactly what I needed.

So I just used my simple code: (Again, not for user production mode, just for repetitive tasks I have to do a lot)

Private Sub btnOpen2Tables_Click()
DoCmd.SelectObject acForm, Me.Name, False
DoCmd.Minimize 'Minimize my work task shortcut MainMenuForm that opens on db open
DoCmd.OpenTable "Table1"
DoCmd.MoveSize 0, 0, 6100, 12100 'The smaller table width
DoCmd.OpenTable "Table2"
DoCmd.MoveSize 6100, 0, 15000, 12100 ''The wider table width
End Sub

Thanks also for having patience with me! smile.gif

--RockManFree

PS: Thanks also to everyone that commented.
Go to the top of the page
 
ADezii
post May 1 2019, 05:49 PM
Post#12



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif
  1. I made the Code more portable by encapsulating the Logic within a simple Sub-Routine Procedure.
  2. Simply pass to this Procedure (PositionTable()) the Table Name, Left Argument, Top Argument, Width Argument, and Height Argument.
  3. The Arguments are also passed as Inches instead of Twips which is more intuitive.
  4. The following Code Segments will Open the Northwind Orders and Order Details Tables. Both will be side by side and have the same Width (5 in.) and Height (8 in.).
  5. Sub-Routine Definition:
    CODE
    Public Sub PositionTable(strTable As String, lngLeft, lngTop, lngWidth, lngHeight)
    Const conTWIPS_PER_INCH = 1440

    With DoCmd
      .OpenTable strTable, acViewNormal, acEdit
      .MoveSize lngLeft * conTWIPS_PER_INCH, lngTop * conTWIPS_PER_INCH, _
                lngWidth * conTWIPS_PER_INCH, lngHeight * conTWIPS_PER_INCH
    End With
    End Sub
  6. Sample Calls to Sub-Routine:
    CODE
    Call PositionTable("Orders", 0, 0, 5, 8)
    Call PositionTable("Order Details", 5, 0, 5, 8)
  7. Simply Download the Attachment for a better explanation.

This post has been edited by ADezii: May 1 2019, 05:50 PM
Attached File(s)
Attached File  Position_Tables.zip ( 33.7K )Number of downloads: 3
 
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th July 2019 - 12:54 AM