Results 1 to 3 of 3
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    242

    Get value from text box on a form

    Hi,


    I have a dialogue for where the user selects two values from two combo boxes and type a number in a third text box. A command button on the form will execute a query to update a value in a table (partial code):
    Code:
    strSQL = "UPDATE tlkpGrades INNER JOIN (tblSchoolYears INNER JOIN tblJoinStudentsYears " _
                    & "ON tblSchoolYears.pkSchoolYears = tblJoinStudentsYears.fkSchoolYears) " _
                    & "ON tlkpGrades.pkGrades = tblJoinStudentsYears.fkGrades " _
                    & "SET tblJoinStudentsYears.TuitionFeesPrevious = 3500 " _
                    & "WHERE SchoolYear='" & Me.cboSchoolYear & "' " _
                    & "AND GradeLevel='" & Me.cboGradeLevel & "' "
                    
                    
       Debug.Print strSQL
       Debug.Print
       db.Execute strSQL, dbFailOnError
    Instead of the the amount 3500, I would like the value to be taken from a text box txtNewTuition on the form frmChangeTuition. I changed strSQL to the following:
    Code:
    strSQL = "UPDATE tlkpGrades INNER JOIN (tblSchoolYears INNER JOIN tblJoinStudentsYears " _
                    & "ON tblSchoolYears.pkSchoolYears = tblJoinStudentsYears.fkSchoolYears) " _
                    & "ON tlkpGrades.pkGrades = tblJoinStudentsYears.fkGrades " _
                    & "SET tblJoinStudentsYears.TuitionFeesPrevious = me.txtNewTuition " _
                    & "WHERE SchoolYear='" & Me.cboSchoolYear & "' " _
                    & "AND GradeLevel='" & Me.cboGradeLevel & "' "
    Running the code shows the following error:
    error 3061: Two few parameters. Expected 1.

    Any idea how to fix this?
    Thanks
    Khalil

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    looks like you are missing a &

    think

    & "SET tblJoinStudentsYears.TuitionFeesPrevious = me.txtNewTuition " _

    should be


    & "SET tblJoinStudentsYears.TuitionFeesPrevious = " & me.txtNewTuition _

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    242
    Thank you very much
    Done

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

Similar Threads

  1. Replies: 5
    Last Post: 07-05-2017, 02:36 PM
  2. Replies: 2
    Last Post: 01-10-2016, 06:47 PM
  3. Replies: 7
    Last Post: 06-05-2015, 11:13 AM
  4. Replies: 1
    Last Post: 03-27-2014, 06:42 AM
  5. Replies: 2
    Last Post: 03-01-2012, 12:21 PM

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