runtime error 2169

mana

Registered User.
Local time
Yesterday, 19:59
Joined
Nov 4, 2014
Messages
265
Hello

when i want to filter my query based on the following code i have runtime error 2169, you can 't save this record at this time but it worked fine before. can you help me? what is the problem?

when i for example want to filter based on febriary i have the following error:


here is my code:

Code:
Private Sub Combo25_Change()
If Me.Combo25.Value = "alle erledigten" Then
 Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE qry_Nacharbeitsmgnt_Reifenfelgenforedit.[erledigt am] IS not NULL"
Me.Requery
End If

 If Me.Combo25.Value = "offene fahrzeuge" Then
 Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [erledigt am] IS NULL"
      Me.Requery
End If
     
     
 If Me.Combo25.Value = "alle daten" Then
 Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit"
   Me.Requery
End If
 
    
 ' If Me.Combo25 = "Jänner" Then
   '  Me.Filter = "Month([erledigt am]) = 1"
    ' Me.FilterOn = True
' Me.Requery
' End If
If Me.Combo25 = "Jänner" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=1"
Me.Requery
End If
 If Me.Combo25 = "Februar" Then
 Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=2"
 Me.Requery
End If
If Me.Combo25 = "März" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=3"
Me.Requery
End If
If Me.Combo25 = "April" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=4"
Me.Requery
End If
If Me.Combo25 = "Mai" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=5"
Me.Requery
End If
If Me.Combo25 = "Juni" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=6"
Me.Requery
End If
If Me.Combo25 = "Juli" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=7"
Me.Requery
End If
If Me.Combo25 = "August" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=8"
Me.Requery
End If
If Me.Combo25 = "September" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=9"
Me.Requery
End If
If Me.Combo25 = "Oktober" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=10"
Me.Requery
End If
If Me.Combo25 = "November" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=11"
Me.Requery
End If
If Me.Combo25 = "Dezember" Then
Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=12"
Me.Requery
End If
end sub
 
sometimes i have the below error message, can you help me please?
what is wrong here ?
i can't understand it?
i attached the error message
 

Attachments

  • Unbenannt.jpg
    Unbenannt.jpg
    70.1 KB · Views: 122
you get points for using the code box but no points for your layout - it is difficult to read and therefore understand - if you want more responses I strongly recommend you layout your code more clearly, with comments and relevant names for controls

However you say it worked before, but there is a fundamental error in it, so I am surprised it has ever worked.

You are using the change event, whereas you are referring to the control value - this will not be populated until the control is updated. The change event is triggered after each change to the control text.

Try moving the code to the combo25 afterupdate event

Just as an aside, you can simplify your code considerably by having a value list with 2 columns

0;"alle daten";1;"Jänner"... etc

then you code would just be

Code:
If Me.Combo25= 0 Then
     Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE qry_Nacharbeitsmgnt_Reifenfelgenforedit.[erledigt am] IS not NULL"
Else
     Me.RecordSource = " SELECT * FROM qry_Nacharbeitsmgnt_Reifenfelgenforedit WHERE [month_erledigt]=" & Me.Combo25
 End If
 

Users who are viewing this thread

Back
Top Bottom