Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272

    Display Bible verses on access forms

    I have a database which I developed for a church. But I will like to have some Bible verses display on the forms at random .



    Is this possible is access?
    If it is, how will that be done?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Your table of verses should have an autonumber PK id field. Use the random function (Rnd) to generate a number between 1 (if that's the lowest ID) and some higher number. If your count of verse records will remain static, you could base the function on that number. If you're going to add records (verses) you'll need to get a count of the records in the table and pass that value to Rnd. If the forms have records that have nothing to do with the verse, then you'll have to use a form textbox whose control source is set via code by using DLookup function. It would return the verse whose ID corresponds to what the Rnd function calculates. You'll also need an event to trigger a control update - probably the Timer event, which is in milliseconds.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Micron View Post
    Your table of verses should have an autonumber PK id field. Use the random function (Rnd) to generate a number between 1 (if that's the lowest ID) and some higher number. If your count of verse records will remain static, you could base the function on that number. If you're going to add records (verses) you'll need to get a count of the records in the table and pass that value to Rnd. If the forms have records that have nothing to do with the verse, then you'll have to use a form textbox whose control source is set via code by using DLookup function. It would return the verse whose ID corresponds to what the Rnd function calculates. You'll also need an event to trigger a control update - probably the Timer event, which is in milliseconds.
    Can you give a practical example so I can understand you better

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Can you give a practical example so I can understand you better
    Of what? Rnd, DLookup, autonumber PK, getting a record count, Timer event, the whole thing? I don't have a working example if that's what you're asking for. Maybe someone will have a better idea for an approach because that one has several elements to it but I'm sure it would work.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,274
    @Isaldogs has a scrolling demonstration DB that you could put up in a disabled textbox, the width of the form ?
    Use that with Micron's random suggestion to select a quote?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Figured I'd play.
    tblVerses fields: VerseID | Verse; ten records with autonumber PK from 1 to 10

    frmVerses with txtVerse textbox; timer event of 10000

    Code:
    Private Sub Form_Timer()
    Dim i As Long, lngID As Long
    
    i = DCount("*", "tblVerses")
    lngID = ((i - 1 + 1) * Rnd + 1)
    
    Me.txtVerse = DLookup("Verse", "tblVerses", "VerseID=" & lngID)
    End Sub
    EDIT - depending on circumstances, might need to deselect text. Since I only have one control on this test form, the text is highlighted. If that occurs then add
    Me.txtVerse.SelLength = 0

    I find the execution stops cursor flashing for about 3 seconds although the event completes on time. Perhaps moving the variables onto the form declaration section would fix that (they wouldn't have to calculate every 10 seconds). Will play some more.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Did you look at the link I provided earlier?
    Anyway, here's a simple example based on an existing rich text example app of mine

    The form you want is frmRandomText.

    EDIT: Just read Micron's last reply. Instead of a command button, you could use a timer event as he suggested. However, as noted, timer events can cause flickering
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    This makes no difference to cursor behaviour in my test
    Code:
    Option Compare Database
    Option Explicit
    Dim i As Long
    
    Private Sub Form_Open(Cancel As Integer)
    i = DCount("*", "tblVerses")
    End Sub
    
    Private Sub Form_Timer()
    Dim lngID As Long
    
    Randomize
    lngID = ((i - 1 + 1) * Rnd + 1)
    Me.txtVerse = DLookup("Verse", "tblVerses", "VerseID=" & lngID)
    Me.txtVerse.SelLength = 0
    
    End Sub
    Developer would have to test effect on user's ability to properly interact with form.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by isladogs View Post
    Did you look at the link I provided earlier?
    Anyway, here's a simple example based on an existing rich text example app of mine

    The form you want is frmRandomText.

    EDIT: Just read Micron's last reply. Instead of a command button, you could use a timer event as he suggested. However, as noted, timer events can cause flickering

    The timer event is somehow conflicting with another timer event I have here. But let me play around it to see a way around

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    You can only have one timer event per form though it is possible you may be able to add the code to your existing timer event code.
    However, it is more likely that the answer is no.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    One way to get around that would be to put the verse on a subform.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Well, the subform and the timer event seems not to work the way I want it. So I will go be Isladogs uploaded file and modify it a little bit to meet my needs.
    Thanks so much to you all for your time and efforts

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Good luck. Come back if you have any issues
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  15. #15
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Noted Man
    I really appreciate your time and efforts

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. New Bible Project help needed
    By JimBell in forum Database Design
    Replies: 11
    Last Post: 02-28-2018, 06:18 PM
  2. Access forms to display records
    By Srin in forum Access
    Replies: 2
    Last Post: 10-16-2015, 01:31 PM
  3. display FORMS UPON OPENING ACCESS FILE
    By vnms2001 in forum Access
    Replies: 3
    Last Post: 06-18-2014, 01:22 PM
  4. how to display a table into vba forms?
    By sunny in forum Access
    Replies: 1
    Last Post: 07-11-2010, 04:33 AM
  5. sorting Bible verses
    By SitarSteven in forum Access
    Replies: 2
    Last Post: 09-08-2009, 07:48 AM

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
  •  
Other Forums: Microsoft Office Forums