Ask Experts Questions for FREE Help !
Ask
    lisabaker's Avatar
    lisabaker Posts: 1, Reputation: 1
    New Member
     
    #1

    Dec 2, 2014, 08:05 PM
    Could someone help me out with VB code?
    Hi,

    I have a problem with my VB code in Access saying 'Run-time error 3075': Syntax Error in query expression '[Survey Questions].*'

    The code is as follows:

    Private Sub Report_Open(Cancel As Integer)

    'Declare Variables
    Dim strR5 As String
    Dim intSeminar As Integer

    'Get the seminar from the Select Seminar form
    intSeminar = Forms![Select Seminar]![cboSelectSeminar]

    'Set the record source
    strR5 = "SELECT [Survey Questions]. * FROM [Survey Questions] WHERE SeminarID =" & intSeminar <------- highlighted
    Me.RecordSource = strR5

    End Sub

    Could someone help me out? My textbook is of no help.

    Thanks in advance!
    Lisa
    GaryStaunton's Avatar
    GaryStaunton Posts: 17, Reputation: 2
    New Member
     
    #2

    Jan 28, 2015, 04:33 PM
    Hi "SELECT [Survey Questions]. * FROM [Survey Questions] WHERE SeminarID =" & intSeminar Why do you have a full-stop here "[Survey Questions]."? I'm guessing this is the problem.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #3

    Jan 28, 2015, 05:08 PM
    Lisa,

    This is VBA code, not VB code. There is a difference. VBA is a superset of VB with extensions specific to the application the code is run from. So your question has been moved to the Access forum.

    The line of code should look like this:

    strR5 = "SELECT [Survey Questions].* FROM [Survey Questions] WHERE SeminarID =" & intSeminar & ";"

    You had a space before the * and no semi colon after concatenating in intSeminar.

    You could shorten the code, since you don't need the intSeminar, you could just use:

    strR5 = "SELECT [Survey Questions].* FROM [Survey Questions] WHERE SeminarID =" & Forms![Select Seminar]![cboSelectSeminar] & ";"

    Frankly, however I wouldn't do it this way. Instead I would do it like this:

    Me.Filter = "[SeminarID] = " & Forms![Select Seminar]![cboSelectSeminar]
    DoCmd.RunCommand acCmdApplyFilterSort

    This allows you to just filter the form by the selected seminar rather then replace the Recordsource.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

2000 honda accord radio security code shows code E [ 0 Answers ]

I had to replace the radio fuse on my 2000 Honda Accord. I have the security code number, but when I enter it, the CD message is code "E". How do I get the radio to play?

Carrier furnace with a red flash code of 2 short and 1 long code [ 2 Answers ]

I have a Carrier and the furnace and the heat will not come on. The fan does come on but the burners will not ignite. I get a red flash code of 2 short and one short. I have the same thermostat upstairs and I switched them and the same result. The upstairs works fine with both thermostats. I have a...

Need code to unlock radio 2000 mitibushi galant es showing code on face [ 0 Answers ]

Can anyone help need code to unlock radio 2000 mitisubishi galant es face just reads code

Write pseudo code reads in course information that includes class code, three digit s [ 1 Answers ]

Design a flowchart or pseudocode for a program that accepts rental contract data and displays a completed rental contract ready for a customer’s signature. Accept the following as input: Contract number Customer’s first and last names Automobile’s vehicle identification number Starting date...


View more questions Search