error 2427

RedHeadedMonster

New member
Local time
Today, 05:45
Joined
Feb 27, 2013
Messages
8
I have the following code:

If Forms!frmIdeas.frmIdeas_Questions.Form.maxQID = 6 Then

Else

Dim sqlQ6 As String
sqlQ6 = "INSERT INTO tblQuestions ( ideaID, questionID) Values (ideaID, 6)"
DoCmd.RunSQL sqlQ6

End if

*Send email code*

And I get the 2427 No data error if there is no data on the first line

So I tried:

If Forms!frmIdeas.frmIdeas_Questions.Form.maxQID is nothing Then

Dim sqlQ6 As String
sqlQ6 = "INSERT INTO tblQuestions ( ideaID, questionID) Values (ideaID, 6)"
DoCmd.RunSQL sqlQ6

Else

End if

*Send email code*

then I dont get the error, It sends the email, but does NOT insert data into table.

Any help is appreciated.
Thanx!
RHM
 
Last edited:
What is the structure of tblQuestions?
What is the datatype of ideaID

In plain simple English, what are you trying to do?

For your reference and use, here are some debugging techniques to help you see the values in your variables and to control processing so you can debug your code.
http://www.cpearson.com/excel/DebuggingVBA.aspx
 
ideaID (Number type) is the primary key for the main table (tblIdeas), in this case it is a secondary key for the question table (tblQuestions) which ties an Idea to to one or more questions (questionID - Number type). tblQuestions also has Memo filed for Answers to the questions.

The insert statement works perfectly if there is a value in maxQID.

Basically what happens is a Manager reviews an idea and decides, hey we need more details and then assigns one of 2 sets of questions to the idea's originator that must be answered. All ideas dont have questions associated with them because, they are not going to be evaluated further. So on a button click from a form, I have the code evaluating in this case the first set of questions, maxQID = 6, if it equals 6 already it will not re-assign the first set of questions since they have obviously already been assigned. however if it is a Null / empty / NOTHING set i need it to assign the questions. Hence my issue with the 2427 error.
I'd appreciate any futher help. Thanx!
 
You do not seem to concatenate the values properly.. It should be..
Code:
sqlQ6 = "INSERT INTO tblQuestions (ideaID, questionID) VALUES ([B]" & ideaID & "[/B], 6)"
 
Ok I change the SQL statement.

But the 2427 error still occurs on the first line

If Forms!frmIdeas.frmIdeas_Questions.Form.maxQID = 6 Then

any other ideas?
 

Users who are viewing this thread

Back
Top Bottom