form with dynamically shifted controls (1 Viewer)

Wysy

Registered User.
Local time
Today, 09:21
Joined
Jul 5, 2015
Messages
333
Hi,
I would like to make a form which shows up the partners of the business in a file box style: not below each other but each being shiifted slightly to the right. Just like in a file box. Is there anyway? I was thinking about repositioning the controls in runtime, but it does not work. Any idea?
thanks
 

June7

AWF VIP
Local time
Today, 08:21
Joined
Mar 9, 2014
Messages
5,479
Each partner is a record? Answer is no.
 

missinglinq

AWF VIP
Local time
Today, 12:21
Joined
Jun 20, 2003
Messages
6,423
The problem is that while, on Continuous or Datasheet View Forms, you may see 'Controls' holding the names of partners...you're not actually seeing multiple Controls, but rather multiple instances of a single Control...and anything done to one instance of that Control is done to all instances of the Control.

Conditional formatting a Control for things like fore color, back color, bolding, etc. and Enabling/Disabling the Control can be done, on individual instances of a Control, using
Conditional Formatting on the Ribbon, but not thins like changing the position of a Control.

Linq ;0)>
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:21
Joined
May 21, 2018
Messages
8,546
Could you provide a picture of what you are asking? What is a "file box"? If I google file box I get images of a box that you put files in. Maybe a tree view?

It is wrong to say that this in not possible. It definitely can be done, but probably not the best solution. You can populate a form at runtime with the necessary controls and position them where you want. You can add and delete controls, but normally less overhead to have a max number of needed controls and hide the ones not used. The only issue like it would have to be an unbound form. So yes it can be done, but the juice may not be worth the squeeze.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 12:21
Joined
Jun 20, 2003
Messages
6,423
Maybe I'm wrong...but I believe that the OP is talking about something like an Index Card Filebox:

https://www.amazon.com/Set-Card-Dividers-labled-Index/dp/B01M6Z3ECC/ref=lp_12900921_1_9?s=office-products&ie=UTF8&qid=1535893523&sr=1-9

where the A, B, C, D, E. etc. in the photo would be replaced with the partner names...In other words, showing multiple Records, in each succeeding Record, the 'partner name' Control would appear adjacent to and just to the right of the same Control on the previous Record...impossible, I'm pretty sure, for the reasons stated.

Linq ;0)>
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:21
Joined
May 21, 2018
Messages
8,546
I have to see a picture, cause I do not really understand. That looks like a tab control to me. Maybe something like this





This would be good up to a reasonable amount of partners. In the above I have 20 possible tabs. Something more than that maybe a tree view.
 

Attachments

  • CardBox.jpg
    CardBox.jpg
    51.4 KB · Views: 137
  • CardBox2.jpg
    CardBox2.jpg
    48.8 KB · Views: 161
  • IndexCardControl 2.accdb
    684 KB · Views: 47
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:21
Joined
May 21, 2018
Messages
8,546
There is really not that much code to do this, if this is what is being asked

Code:
Private Sub cmboFirm_AfterUpdate()
  If Not IsNull(Me.cmboFirm) Then LoadPages (Me.cmboFirm)
    
End Sub

Private Sub Form_Load()
  Dim i As Integer
  Me.TxtFocus.SetFocus
  For i = 0 To Me.tabCtlIndex.Pages.Count - 1
    Me.tabCtlIndex.Pages(i).Visible = False
  Next i
  Me.TxtFocus.SetFocus
  Me.subFrmPartner.Visible = False
End Sub

Public Sub LoadPages(FirmName As String)
  Dim RS As DAO.Recordset
  Dim tc As TabControl
  Dim PartnerCount As Integer
  Set tc = Me.tabCtlIndex
  
  Set RS = CurrentDb.OpenRecordset("Select * from TblPartners where FirmName = '" & FirmName & "'")
  If Not RS.EOF And Not RS.BOF Then
    RS.MoveLast
    RS.MoveFirst
    PartnerCount = RS.RecordCount
   ' AddNames
  End If
  Me.Painting = False
  Me.TxtFocus.SetFocus
  AddNames RS
  HidePages 0
  ShowPages PartnerCount
  Me.subFrmPartner.Visible = True
  Me.Painting = True
End Sub

Public Sub HidePages(PartnerCount As Integer)
  Dim i As Integer
  For i = PartnerCount To Me.tabCtlIndex.Pages.Count - 1
    Me.tabCtlIndex.Pages(i).Visible = False
  Next i
End Sub
Public Sub ShowPages(PartnerCount As Integer)
  Dim i As Integer
  For i = 0 To PartnerCount - 1
    Me.tabCtlIndex.Pages(i).Visible = True
  Next i
End Sub
Public Sub AddNames(RS As DAO.Recordset)
  Dim PartnerName As String
  Dim i As Integer
  Do While Not RS.EOF
     PartnerName = RS!FullName
     With Me.tabCtlIndex.Pages(i)
       .Caption = PartnerName
       .Tag = RS!PartnerID
     End With
     i = i + 1
     RS.MoveNext
  Loop
End Sub

Private Sub tabCtlIndex_Change()
  LinkSubForm
End Sub
Private Sub LinkSubForm()
  Dim PartnerID As Long
  Dim strID As String
  strID = Me.tabCtlIndex.Pages(Me.tabCtlIndex.Value).Tag
  If strID = "" Then strID = "0"
  PartnerID = CLng(strID)
  Me.subFrmPartner.Form.Recordset.FindFirst "PartnerID = " & CLng(PartnerID)
End Sub
 

Wysy

Registered User.
Local time
Today, 09:21
Joined
Jul 5, 2015
Messages
333
Thank you. That is exactly what i looked for.
 

June7

AWF VIP
Local time
Today, 08:21
Joined
Mar 9, 2014
Messages
5,479
Nice! I should have said "No, not without code." Most anything can be done with enough code.
 

Users who are viewing this thread

Top Bottom