I'm going to try this again. I have got somewhere, but now I'm stuck.
I have created a form that will be the find dialog popup. On it, so far I have 2 fields - first name and last name, however I will have a number of other fields, including address, D.O.B. and parent's names. This is to be a multi-talented find form that calls up the sought after record based on the input names (and whether all/some/one of the fields are used). However, I don't know how to get the code to ignore a field if it is left blank. It simply searches for the record with a Null value for the first name for example. Also, I am trying to work with IIf statements within the Where conditions of the OpenForm command. Access doesn't have a problem with the syntax when I type it, however it gives me an expected expression error when I run it.
This looks rather convoluted, but it is supposed to work. I don't know why I need the '= [CLIENT LIST]' at the end -
but I get an expected = error otherwise
DoCmd.OpenForm([CLIENT LIST], , , IIf([Forms]![Find]![cfirst] Is Null, "", [Forms]![Find]![cfirst] = [CLIENT LIST]![CLIENT NAME (FIRST)]) And IIf([clast] Is Null, "", [Forms]![Find]![clast] = [CLIENT LIST]![CLIENT NAME (LAST)])) = [CLIENT LIST]
Thanks. I know this isn't brief, but help would be greatly appreciated.
Ben
I have created a form that will be the find dialog popup. On it, so far I have 2 fields - first name and last name, however I will have a number of other fields, including address, D.O.B. and parent's names. This is to be a multi-talented find form that calls up the sought after record based on the input names (and whether all/some/one of the fields are used). However, I don't know how to get the code to ignore a field if it is left blank. It simply searches for the record with a Null value for the first name for example. Also, I am trying to work with IIf statements within the Where conditions of the OpenForm command. Access doesn't have a problem with the syntax when I type it, however it gives me an expected expression error when I run it.
This looks rather convoluted, but it is supposed to work. I don't know why I need the '= [CLIENT LIST]' at the end -
but I get an expected = error otherwise
DoCmd.OpenForm([CLIENT LIST], , , IIf([Forms]![Find]![cfirst] Is Null, "", [Forms]![Find]![cfirst] = [CLIENT LIST]![CLIENT NAME (FIRST)]) And IIf([clast] Is Null, "", [Forms]![Find]![clast] = [CLIENT LIST]![CLIENT NAME (LAST)])) = [CLIENT LIST]
Thanks. I know this isn't brief, but help would be greatly appreciated.
Ben