Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2014
    Posts
    5

    Unanswered: Fill list box with text file content access 2010 vba

    Hi all,

    I am a newcomer to the forum and am building a small access 2010 membership application for a non-profit charity. My background is maintly excel and oracle SQL developer with basic knowledge of vba. Having said that, I am familiar with using ADO and DAO recordsets.

    My first challenge on this forum is probably quite simple so please be tolerant of me! Like most, I am eager to learn new skills in here!

    Now, i have a EULA that is a text file, a form named "frm_about" and a single column listbox with its row source property set to value list named "lst_eula".

    What i am wanting to do is to populate the list box with the contents of the EULA text file when the user opens the form.

    Below is my code thus far.

    Code:
    Private Sub cmd_eula_Click()
    On Error GoTo Err_Handler
    
       Dim prj As Object
    
       Set prj = Application.CurrentProject
    
       If prj.AllForms("frm_about").IsLoaded Then
          Forms![frm_about].Visible = True
       Else
          DoCmd.OpenForm "frm_about"
       End If
       
    ErrorHandlerExit:
       Exit Sub
    
    Err_Handler:
       If Err.Number = 0 Then
          Resume ErrorHandlerExit
       Else        
            Call addbLog(6, "System execute failure | error number : " & Err.Number & ", error description:  " & Err.Description & "")
              Resume ErrorHandlerExit
       End If
    End Sub
    Has anyone got any ideas on the best way to tackle this without storing the EULA content in a table?

    Thanks in advance.

    yogi

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    personally Id store it in a text file, and display it in a RTF or multi line control
    storing in a combo or listbox isn't going to work that well as a list box is a list of options.
    if you break down your EULA into lines it may be able to be coerced into working
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2014
    Posts
    5
    Hi there,

    Thanks for your response.

    Sounds like the first option is best in this case. So lets say I change my list box to a text box instead ("txt_eula"), how would you go about retrieving the contents of the text file and populating it?

    I know how to locate the file as it is stored in the CurrentDB directory and has the name EULA.txt.

    Thanks.
    YB

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    the easiest is going to be to stick it directly into a form
    do you expect to be changing your ELUA during the life of the applciation?
    if you expect the EULA to have any meanign then you have to protect it agaisnt modification. assuming you deploy the app using an encrypted file (MDE or ACCDE) then they user can't tinker with whats inside the app. so I'd just stuff it directly into a control.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Aug 2014
    Posts
    5
    I have added the text box to the form now and have populated it with some vb script. I don't like the look of it but i guess these cosmetic limitations are the shortcomings of developing in the access environment.

    Code:
    Function populate_EULA()
    
    Dim sTxt$, sText$, sPath$
    
        sPath = CurrentProject.path & "\EULA.txt"
        If Dir(sPath) = "" Then
            MsgBox "File was not found."
            Exit Function
        End If
        Close
        Open sPath For Input As #1
        Do Until EOF(1)
            Line Input #1, sTxt
            sText = sText & sTxt & vbLf
        Loop
        Close
        sText = Left(sText, Len(sText) - 1)
        Forms("frm_about").Controls("txteula") = sText
    
    End Function
    The EULA may change with legal advancements so its best to allow for the file to come from outside the application i.e. in its resident directory.

    To stop user from making modifications I have locked the control on the form and display as read only locked.

    I intend on deploying the solution as a split db using access 2010 RT.

    Thanks for all the tips.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and what is there to stop someone changing the text file that your EULA relies on?

    if there is a need for a legal change issue a new front end containing the revised EULA

    as to presentation issues, bear in mind I suggested using a RTF control
    Insert or add a rich text field - Access
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Aug 2014
    Posts
    5
    While it is unlikely that anyone will have the technical knowledge required to amend the file, you're quite right, there is nothing protecting it from unauthorized modification.

    I am looking into the link you sent as this appears to be a great alternative to overcoming this problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •