Search results

  1. Z

    A little help with If, Else and Exit sub

    No - it opens the form showing the records matching the employee ID where off is equal to 0. Off=0 is set when Stop time field (Which is a date field) is empty
  2. Z

    A little help with If, Else and Exit sub

    Hi This works Thanks... :-) However, the form opens even though both criteria aren't met. So I ended up with this: Private Sub btn_StopOrdre_Click() Dim intanswer As Integer If cbm_Medarbejder = "" Then intanswer = MsgBox("Husk at vælge medarbejder fra dropdown listen", 64, "Vælg...
  3. Z

    A little help with If, Else and Exit sub

    If "cbm_Medarbejder" empty then msgbox If cbm_Medarbejder = "" Then intanswer = MsgBox("Husk... Vælg medarbejder fra dropdown listen", vbOKOnly) Forms!frm_ctn_list!cbm_Medarbejder.SetFocus Exit Sub Else so far so good :) Instead of checking a query's outcome it might be better...
  4. Z

    A little help with If, Else and Exit sub

    Well "cbm_Medarbejder" is on the current form but the "Off" field is located in table "tbl_TidsTabel" Am I missing a table reference here ?
  5. Z

    A little help with If, Else and Exit sub

    Hi Thanks for the quick reply :) I must be doing something wrong. It looks like the first criteria is ignored as it goes to the DoCmd.OpenForm... where I get an error cause "cbm_Medarbejder" isn't filled out yet - this makes sense. However maybe I have a syntax error i my opening criteria for...
  6. Z

    A little help with If, Else and Exit sub

    I have a form where a production order can be stopped by the button "btn_StopOrdre". However certain conditions must bet met in order to do this. First criteria - If no choice has been made in combo box "cbm_Medarbejder" a message box tells the operator to fill it out. Second criteria - If the...
  7. Z

    If statement with two criteria

    Thanks.. Maybe my logic is off. I cant seem to make it work First I make sure that the user has made a choice in the combobox with this. Dim intanswer As Integer If IsNull(Forms!frm_ctn_List!cbm_Medarbejder) Then intanswer = MsgBox("Husk... Vælg medarbejder fra dropdown list"...
  8. Z

    If statement with two criteria

    I am not sure how to add the last criteria. I get an error on this one If DLookup("[MedarbejderID]", "tbl_TidsTabel", "MedarbejderID = " & cbm_Medarbejder.Value & "") And [On] = 0 Then
  9. Z

    If statement with two criteria

    Hi I have a button on form "frm_ctn_List" called btn_StopOrdre. In the "on click" event of this I would like to show a msgbox if field [MedarbejderID] in table "tbl_TidsTabel" equals combobox "cbm_Medarbejder" value. and field [On] in table "tbl_TidsTabel" equals 0 Otherwise open form...
  10. Z

    Combobox value for multiple filter criteria in a Query

    Actually there are values from 0 to 4 which represents different status of productions orders. I only need to work with status 3, correct, but I was just trying to change something to see if I could get it working :)
  11. Z

    Combobox value for multiple filter criteria in a Query

    Tried to make Location Code and Production Order status cbm selections, but I get a missing operator error. When the actual code of an cbm selection after update event is placed in another cbm after update like this is. Could that work, or should each "If" statement be placed in the after update...
  12. Z

    Combobox value for multiple filter criteria in a Query

    It kind of semi works now :) I still have the record source set to the original query but removed the criteria set there for the above fields. Otherwise I still get no destination fields. However the DepartmentSelection filter does work for for some of the selections which is kind of strange...
  13. Z

    Combobox value for multiple filter criteria in a Query

    Hi again I get a data type mismatch error. tbl_Status.Status_Status is a number dbo_KonfAir DRIFT$Production Order].Status is a number dbo_KonfAir DRIFT$Production Order].[Location Code] is a short text field dbo_KonfAir DRIFT$Item].[Item Category Code] is a short text field strSQL = strSQL &...
  14. Z

    Combobox value for multiple filter criteria in a Query

    Hmmm... Still not there yet If the record source is set to the initial Query and I open the form, it open up correctly. But when I change combo box value I get the attached error. If I set the record source to strSQL I get "Query must have at least one destination field" I have another combo...
  15. Z

    Combobox value for multiple filter criteria in a Query

    When I do that I get the error attached referring to setting the recordsource to strSQL Me.RecordSource = strSQL I can open the form. The error occurs when updating the combo box
  16. Z

    Combobox value for multiple filter criteria in a Query

    Do I need to put the tables and fields inside the Query builder for the form to find the record source ? Yes... it was first created in a query and initially used as record source. Now, if I change it to strSQL then I get the error "Query must have at least one destination field"
  17. Z

    Combobox value for multiple filter criteria in a Query

    Thanks :) Isn't the record source suppose to be set to strSQL, like the attached image. I get an error that the record source doesn't exists
  18. Z

    Combobox value for multiple filter criteria in a Query

    Hi again I have tried to insert the code into my SQL, but I get an error after the "Where" clause. I can see the issue in appending "And" after the "Where" clause but do not know how the syntax should be. Private Sub cbm_DepartmentSelection_AfterUpdate() strSQL = "SELECT [dbo_KonfAir...
  19. Z

    Combobox value for multiple filter criteria in a Query

    Thanks a lot... You are fast :-) This i just the functionality I am looking for. However this is just a part of a Query. I need to put the rest of the SQL into the VBA Code. Or maybe divide it Would that be possible?? Your code replaces the switch function. SELECT [dbo_KonfAir DRIFT$Sales...
  20. Z

    Combobox value for multiple filter criteria in a Query

    I had some time to look at this again and I made a small sample where I try filter by type and there are more than one criteria. Value 1 in cbm box should filter "Nummer" by 1 and 6 to show all kitchen elements and so on. But something is wrong in the SQL filter expression. I hava attached the...
Top Bottom