Results 1 to 6 of 6
  1. #1
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47

    trouble with control on default value in form

    I have written a simple VBA to change font size due to space limitation of a bounded field [PACKTERMS] which I control by a group option viz. [ShrinkPkg]. The default value of [ShrinkPkg] in table is 1.
    I have bounded [ShrinkPkg] with impression that [PACKTERMS] can be controlled independently by [ShrinkPkg]. Below is the code written:

    Private Sub ShrinkPkg_AfterUpdate()
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    If ShrinkPkg.Value = 1 Then
    Me.PACKTERMS.FontSize = "8"
    ElseIf Me.ShrinkPkg.Value = 2 Then
    Me.PACKTERMS.FontSize = "7"
    ElseIf Me.ShrinkPkg.Value = 3 Then
    Me.PACKTERMS.FontSize = "6.5"
    End If


    End Sub

    =====
    My problem with the above is the control of fontsize of all the records which will automatically change upon each AfterUpdate. I want [PACKTERMS] of every row of record to have fontsize 8, but if option 2 or 3 is selected,
    only that particular record will be affected, or else return to default value of 1 or size 8. However, this is not the case as afterupdate of 1 record to option 2 or 3 will change all records, even new row of record to the selected option.

    Can anyone help me to finetune the code ?

    Thanks for any help render.

    Regards
    Kiang

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Are you using a continuous form? I do not think you are going to get the results you are after if you are using DS view or a continuous form. The intrinsic Conditional Formatting tool may be what you are after.

  3. #3
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Quote Originally Posted by ItsMe View Post
    Are you using a continuous form? I do not think you are going to get the results you are after if you are using DS view or a continuous form. The intrinsic Conditional Formatting tool may be what you are after.
    It is single form. I don't know how but solved by replacing with the quote below :

    Dim FSize As Integer
    Select Case Me.ShrinkPkg.Value
    Case 1
    FSize = 8
    Case 2
    FSize = 7
    Case Else
    FSize = 6

    End Select
    Me.PACKTERMS.FontSize = FSize
    End Sub

    Thanks for your response & suggestion. Really appreciated it.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Interesting, I would have thought the property would want literal text and the quotes were appropriate.
    Me.PACKTERMS.FontSize = "6.5"

  5. #5
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Quote Originally Posted by gykiang View Post
    It is single form. I don't know how but solved by replacing with the quote below :

    Dim FSize As Integer
    Select Case Me.ShrinkPkg.Value
    Case 1
    FSize = 8
    Case 2
    FSize = 7
    Case Else
    FSize = 6

    End Select
    Me.PACKTERMS.FontSize = FSize
    End Sub

    Thanks for your response & suggestion. Really appreciated it.
    The above worked fine for me, but when I attempted to modify to fit another option group in selection of field texts, it didn't work with runtime error. Below is the modification :

    Private Sub SelectHICL_AfterUpdate()Dim HICL As String
    Select Case Me.SelectHICL.Value
    Case 1
    HICL = " "
    Case 2
    HICL = (Me![INSHI])
    Case 3
    HICL = (Me![INSCL])
    Case Else
    HICL = (Me![INSHICL])
    End Select
    Me.SelectHICL.Value = HICL
    End Sub


    All [INSHI], [INSCL], [INSHICL] are texts fields and suppose to fit into [SelectHICL] upon selection.

  6. #6
    gykiang is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    47
    Quote Originally Posted by gykiang View Post
    The above worked fine for me, but when I attempted to modify to fit another option group in selection of field texts, it didn't work with runtime error. Below is the modification :

    Private Sub SelectHICL_AfterUpdate()Dim HICL As String
    Select Case Me.SelectHICL.Value
    Case 1
    HICL = " "
    Case 2
    HICL = (Me![INSHI])
    Case 3
    HICL = (Me![INSCL])
    Case Else
    HICL = (Me![INSHICL])
    End Select
    Me.SelectHICL.Value = HICL
    End Sub


    All [INSHI], [INSCL], [INSHICL] are texts fields and suppose to fit into [SelectHICL] upon selection.
    Sorry, please ignore if read this.

    I found the mistake. The field to be updated should be [SelectOCHICL]

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trouble adjusting size of control
    By ESYO in forum Forms
    Replies: 1
    Last Post: 04-12-2013, 06:26 AM
  2. Replies: 2
    Last Post: 06-05-2012, 08:31 PM
  3. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  4. Replies: 0
    Last Post: 04-12-2011, 10:37 AM
  5. Updating Default Value of a Subform Control
    By eww in forum Programming
    Replies: 4
    Last Post: 04-11-2011, 12:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums