i thought I had solved but... Here is my problem.
when searching for a phone number (stored in TBLClienti.Telefono1, 2 and in TBLPersoneTelefonoDiretto, etc.)
I use this code:
Code:
Private Sub CMDTrovaConTelefono_Click()Dim strSQL As String
strSQL = "SELECT TBLClienti.Telefono1, TBLClienti.Telefono2, TBLClienti.Telefono3, TBLPersone.TelefonoDiretto, TBLPersoneCellulare" & _
"FROM TBLClienti " & _
"INNER JOIN TBLPersone ON TBLClienti.CodiceCliente = TBLPersone.CodiceCliente "
If Me.Telefono & "" = "" Then
MsgBox "Inserire un valore nel campo TELEFONO", vbQuestion, "COSA CERCHI?"
Me.Telefono.SetFocus
Exit Sub
End If
DoCmd.OpenForm "MSKRisultatoRicercaXTelefono", , , WhereCondition:="TBLClienti.Telefono1 LIKE ""*" & Me.Telefono & "*"" OR TBLClienti.Telefono2 LIKE ""*" & Me.Telefono & "*"" OR TBLClienti.Telefono3 LIKE ""*" & Me.Telefono & "*"" OR TBLpersone.TelefonoDiretto LIKE ""*" & Me.Telefono & "*"" OR TBLpersone.Cellulare LIKE ""*" & Me.Telefono & "*"""
End Sub
The two tables, TBLClienti and TBLPersone are linked in the form MSKRisultatoRicercaXTelefono with this SQL:
Code:
SELECT TBLClienti.Telefono1, TBLClienti.Telefono2, TBLClienti.Telefono3, TBLPersone.TelefonoDiretto, TBLPersone.Cellulare, TBLClienti.NomeAzienda, * FROM TBLClienti INNER JOIN TBLPersone ON TBLClienti.CodiceCliente = TBLPersone.CodiceCliente;
It works well as long as the searched number exists and is found. If I input a non existent phone number, like 11111111 then the result form (MSKRisultatoRicercaXTelefono) opens without showing any result but soon after the programme crashes, closes acccess and automatically reopens asking for a backup of the database.
help!