PC Pals Forum

Technical Help & Discussion => Windows PCs & Software: Help, News & Discussion => Topic started by: Biglad on August 19, 2005, 10:40

Title: Access 2000 sub form combo box
Post by: Biglad on August 19, 2005, 10:40
Hello,

I have a combo box on a subform that when i enter a value that is not in the list. it adds the value to the table that holds the values in the combo box. This part works fine.

But i still recieve the message that the value is not in the list. I think this is because the query that runs to display the apropriate values in the combo box needs to be requeried.

As such at the end of my code i have placed a requeary command for the control. When i do this i am informed that i must save the control first.

I hope someone can help me solve this sticky problem.

Here is the code for the Not in List action.

My Main form is called [View Reps] and my subform is called [Questionaire]

Private Sub ResponseT_NotInList(NewData As String, Response As Integer)
Dim respt As String
Dim quest As String
Dim stDt As Date
Dim enDt As Date
Dim sSQL As String

respt = ResponseT.Text

quest = Me.Question

stDt = DLookup("[DT_START]", "tbl_QAR", "[Question]=" & Chr(34) & quest & Chr(34))
enDt = DLookup("[DT_END]", "tbl_QAR", "[Question]=" & Chr(34) & quest & Chr(34))

sSQL = "INSERT INTO tbl_QAR ( Question, ResponseT, DT_START, DT_END ) " & _
        "VALUES (" & Chr(34) & quest & Chr(34) & ", " & Chr(34) & respt & Chr(34) & ", " & _
        Chr(34) & stDt & Chr(34) & ", " & Chr(34) & enDt & Chr(34) & ") ;"

DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True

ResponseT.Requery

End Sub

Many thanks Craig.
Title: Access 2000 sub form combo box
Post by: Clive on August 19, 2005, 18:46
You will probably have to wait for DJ or Sam to help you on this one Craig.  Sam is away until tomorrow evening.
Title: Access 2000 sub form combo box
Post by: DJ on August 19, 2005, 23:05
Hi

Sorry I'm not too clued up on forms and subforms in access. Most the stuff I've done is just a dumb database (basic tables and queries) accessed by an ASP.net front end.

Will have a think though!

Maybe Sam will be able to help out? (No pressure  :laugh: )

DJ
Title: Access 2000 sub form combo box
Post by: sam on August 21, 2005, 00:21
like DJ this isnt my area of expertise - I'll have a look at it tomorrow when my mind is working a bit better and hopefully I will be of some use, at the very least maybe pushing you in the right direction. sorry about the delay.