Results 1 to 8 of 8
  1. #1
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50

    Form for Spanish Vocabulary drills

    I have created a form feed by a table with fields "Spanish" and "English" for meanings where record one is "hola" and "Hi", for example. I want to hide the Spanish word field until I have tried to guess the word and click on a button. Seem to be able to do that ok by changing the visible property.



    but I am having a little trouble moving from word to word. Ideally I would like to move the a word randomly - that is, I am going to start anticipating where the word comes in my drill session "adios" always follows "hola" for example. Is there a way to have a button that moves randomly a another record and resets the visible property on the spanish word?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    If I understand, you'd want a combination of random function to generate a number, then GoTo to go to that record number. However, you will probably end up with repeats as there'd be no guarantee that you'll not repeat the same record a few times out of several iterations. So then what? Remove the viewed ones from a list? That would require a different approach. An array might work, but if you can remove elements in the middle of an array (the value of the record position you've already viewed), I've never done it so I don't know if you can. It would be simpler to use a staging table (one that you populate with the same records as what is in your primary domain) and run a delete query against the staging table. When you're done testing, just delete any leftover records from the staging table until next time. So you do the GoTo against the records in the staging table. Your button click would have to hide the control, get the record and place the value into the hidden textbox. I suppose a 2nd button to show the textbox would be simple enough.

    Forgot to mention that your use of the Rnd function would be against the count of remaining records in the staging table.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    Thank you Micron for your thorough and detailed answer. I do not really care about repeating words in a drill session. I have used this code and I do get movement to a random record when I click the next button:

    Private Sub Next_Click()
    Dim X As Integer
    Dim Upper As Integer
    Upper = Me.Form.Recordset.RecordCount
    X = Int((Upper - 1 + 1) * Rnd + 1)
    DoCmd.GoToRecord acDataForm, "frmSpanishWordsAndPhrases", acGoTo, X
    End Sub

    HOWEVER, neither the Spanish or English word field is populated! I can't understand why.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Stan

    Perhaps attached db will help:
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    HOWEVER, neither the Spanish or English word field is populated! I can't understand why.
    I'd say that has nothing to do with the code you posted. If Bob's db doesn't help, post back.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Stan Denman is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    50
    Thank you so much Bob for your coding advice. It does not indeed work. Would you mind, for my learning purposes, explaining a little about your code? For example, I do not understand the us of the unbound control "lstWords" and the use of two additional tables. Thanks.

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I'm in meeting at the moment but I shall answer you later

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Stan Denman View Post
    Thank you so much Bob for your coding advice. It does not indeed work. Would you mind, for my learning purposes, explaining a little about your code? For example, I do not understand the us of the unbound control "lstWords" and the use of two additional tables. Thanks.
    Stan,
    The db has a table of words. Each record has a PK, an English word and a ..... well I was about to say, a Spanish word with the same meaning, but as you will surely have deduced already I know no Spanish so I have used the English word prefixed with "s" .
    On the form there is a hidden listbox control which is populated with data from the table. There are also two textbox controls. One for the English word and one for the Spanish word. They get their data by using an expression as the Control Source property for each of them that uses an appropriate column of the hidden listbox. The column count of a listbox/combobox has a zero base. So, the first column is .Column(0) the second is .Column(1) etc. The second of these textboxes, the Spanish one, is hidden but is made visible by the adjacent button.

    When Clicked, the button adjacent to the English textbox:
    1) hides the Spanish textbox.
    2) Gets a random number between 1 and the Total number of records in the "Words" table using the expression: Int((DMax("WordID", "tblWords") - 1 + 1) * Rnd + 1)3)
    The integer value returned by that expression is used to select row in the hidden listbox.
    I hope my explanation clarifies the how it all works but if you have any further question please do post back with them.

    There are probably other ways to accomplish the result you require. This was just the first that came to mind for me.

    EDIT:
    I should have mentioned that the table for this example is using an Auto-Number field for my convenience when entering the initial records.
    For the app to work it is important that the records are numbered sequentially from 1, so a number field might be a better choice. Creating the next number would then be done as the form being used to create records, is updated.
    Last edited by Bob Fitz; 09-07-2020 at 12:57 AM. Reason: More Info
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 5
    Last Post: 05-02-2014, 02:01 PM
  2. Vocabulary Project
    By Mina Garas in forum Access
    Replies: 3
    Last Post: 02-27-2013, 09:20 AM
  3. vba vocabulary
    By mejia.j88 in forum Programming
    Replies: 1
    Last Post: 01-16-2012, 01:30 PM
  4. Translate English to Spanish
    By marge0513 in forum Import/Export Data
    Replies: 0
    Last Post: 05-28-2009, 10:09 AM

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