Results 1 to 4 of 4
  1. #1
    R My is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    2

    Select * from problem on form

    I am using an unbound form in MS Access to: 1) select an "event venue" via combo box, 2) select pre-registered participants to the event via cascading combo box, thus filling in form data such as last name, first name, etc from "Paticipants" table relative to each venue.


    This all works...next I add data to four new fields based upon participant desired activities.
    I need to now "read" all of the form data and send it to table "B" or "c" dependent upon the combo box selected "Venue". Tables "B" and "c" have corresponding fields equal to the form. Using the below code. The IF statement works fine, but when the command button is clicked, the "set rec=db.OpenRecordset("select * from " & strMytable & "") line returns a "From clause error." I have tried all that I can think of....any help? Thanks in advance. Just trying to get this one database done. First time using Access. Thanks
    Private Sub Command129_Click()

    Dim db As Database
    Dim rec As Recordset
    Dim strMytable As String

    Set db = CurrentDb
    If Me.Combo77.Value = "Cherry Creek 2019" Then
    strMytable = "CC tourny results"
    ElseIf Me.Combo77.Value = "Pueblo 2019" Then
    strMytable = "pueblo tourny results"
    End If

    sec rec=db.OpenRecordset("select * from " & strMytable & "")

    rec.AddNew
    rec("Last Name") = Me.LastName.text
    rec.Update

    rec.Close
    db.Close

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you are making this too hard...
    the combo should get its data from a query and have 2 fields: Caption, Query
    "Cherry Creek 2019", "qsCCResults"
    "Pueblo 2019",
    "pueblo tourny results"
    etc

    you can set the 2nd column width to zero so users cannot see it.
    combo is bound to col2, then when user picks the item it runs that query

    docmd.openQuery me.cboBox

    this prevents you from having to recode when you add new combo values.

    then you update table B or C with an append query
    openquery "qaAddData"

    this uses the query in cboBox as source to add to target.
    very little coding needed in
    Access. You can do most of it with queries and macros.

  4. #4
    R My is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2019
    Posts
    2
    Thank you for your reply. Great suggestions for a 72 year old fumbling through his first Access programming. I appreciate your comments.

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

Similar Threads

  1. Select Count Problem
    By ndehhh in forum Programming
    Replies: 2
    Last Post: 10-19-2015, 02:56 PM
  2. Ctrl-Select problem
    By Maria in forum Access
    Replies: 3
    Last Post: 11-28-2011, 10:27 AM
  3. select case problem
    By Mclaren in forum Programming
    Replies: 3
    Last Post: 11-17-2011, 01:28 PM
  4. Problem with Select DistinctRow
    By bgus in forum Forms
    Replies: 1
    Last Post: 04-27-2010, 03:27 PM
  5. SELECT problem with apostrophies
    By BPak in forum Programming
    Replies: 7
    Last Post: 07-06-2009, 07:22 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