Results 1 to 9 of 9
  1. #1
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18

    Embedded SQL issue with Combo update



    Code:
    Public Sub cboDate_AfterUpdate()
    
    Dim strSQL As String
    Dim intShootID As Integer
    
      intShootID = Me.cboDate.Value
    
    strSQL = "SELECT tblCompetition.[Shoot_ID], tblCompetition.[Shooter_ID], " & _
                "tblCompetition.[Calibre_ID], tblCompetition.[Class_ID], tblCompetition.[Projectile_Weight], " & _
                "tblCompetition.[Round_1_Score], tblCompetition.[Round_2_Score], tblCompetition.Round_3_Score, " & _
                "tblCompetition.[Round_4_Score], tblCompetition.[Round_5_Score], tblCompetition.[Round_6_Score], " & _
                "tblCompetition.[Competition_Total] " & _
             "FROM tblCompetition " & _
             "WHERE tblCompetition.Shoot_ID = " & intShootID & ";"
    
    Me.RecordSource = strSQL
    
    End Sub
    With this code im getting the following error:



    It hightlights the Me.RecordSource = strSQl line but I cant figure it out. Where is the mismatch? Both sides of the equation are strings?

    Am I missing something?

    One thing I did notice was in the local variable watcher the sql statement was incomplete as if the variable length wasnt long enough. Could this be an issue or is that more related to the size of the field in the Variable watcher?

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Is cboDate an integer? Sounds like a date.

  3. #3
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18
    File is located below.

    wetsphere.com/images/PistolDB.zip

    cboDate is an integer as you will see in the code. I am only referencing the ID column. Perhaps this is an issue though but the variable watcher seems to be pulling back the correct values.

    I no longer get the data mismatch error but it still doesn't populate the datasheet.

    Any assistance would be much appreciated.

  4. #4
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18
    Sorry. The form you want is frmCompDS.

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Does the sql string work in a regular query (if you copied it to query design and ran it stand-alone)?

    You may be missing the Me.Requery statement after you have changed the recordsource.

  6. #6
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18
    Yeah the SQL is fine.

    I was under the impression that changing the record source property would trigger a requery anyway. Either way I added one in to no effect.

  7. #7
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18
    I find that when I use the drop down at the top of the frmCompDS form to select a date then it actually creates a record instead of returning a record.

    Any idea why this is or how to stop it?

    http://wetsphere.com/images/PistolDB.zip

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sorry for the delay - are you still having problems?

  9. #9
    Fatti is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    18
    No I ended up just creating a new data sheet form with a filter in the header. Not sure it's the best way to do what I wanted though. Thanks anyway.

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

Similar Threads

  1. Update query issue
    By doomy304 in forum Queries
    Replies: 2
    Last Post: 06-25-2011, 02:31 PM
  2. Back color update issue
    By GraemeG in forum Programming
    Replies: 3
    Last Post: 03-21-2011, 11:32 AM
  3. Current Record Update Issue
    By SALPBE in forum Programming
    Replies: 0
    Last Post: 02-23-2011, 03:02 PM
  4. Update Query Performance Issue
    By Amber_1977 in forum Queries
    Replies: 2
    Last Post: 12-07-2010, 08:36 AM
  5. Replies: 0
    Last Post: 07-13-2010, 07:45 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