good evening every one
i have a form to enter a new client if the client is existed then a message box appear and tell me that this client is existed and his number id is ## with two buttons yes and no
if i click yes i should go to a report that contains information about that user
and this report take his data from a query
new client save code
---------------------
Dim MSG As Integer
Dim ExistentID As Long
ExistentID = Nz(DLookup("P_ID", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N"), 0)
If ExistentID > 0 Then
'--------------------------
MSG1 = MsgBox("this client is existed and his id number is {" & [ExistentID] & "}, do you want to see his information ", vbYesNo + vbQuestion + vbMsgBoxRtlReading, "client database")
If MSG1 = vbYes Then
DoCmd.OpenReport "rpt_personal_information", acViewPreview, , "[PIDDD] = " & [ExistentID]
Else
End If
Else
strsql101 = "insert into tbl_Personal_Information (Name_English, Father_English, Family_English, Mother_English, P_ID, NName, Father, Family, Mother, Birthdate, Nationality, Record_Number, Record_Place, Address, Mobile1, Mobile2, Phone1, Phone2, Ets_Name) Values ('" & Me.Name_English & "','" & Me.Father_English & "','" & Me.Family_English & "','" & Me.Mother_English & "','" & Me.PID & "','" & Me.NName & "','" & Me.Father & "','" & Me.Family & "','" & Me.Mother & "','" & Me.Birthdate & "','" & Me.Nationality & "','" & Me.Record_Number & "','" & Me.Record_Place & "','" & Me.Address & "','" & Me.Mobile_1 & "', '" & Me.Mobile_2 & "','" & Me.Phone_1 & "', '" & Me.Phone_2 & "','" & Me.Ets_Name & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql101
'--------------------------
MSG2 = MsgBox("information added succesfully, do you want to add a new record", vbYesNo + vbQuestion + vbMsgBoxRtlReading, "client database")
If MSG2 = vbYes Then
DoCmd.Close acForm, "frm_New_Person"
DoCmd.OpenForm "frm_New_Person"
Else
DoCmd.OpenForm "frm_Entering_Data"
DoCmd.Close acForm, "frm_New_Person"
End If
End If
note that PIDDD is a textbox in the report that it's bounded with P_ID in the query
my problem is this line
DoCmd.OpenReport "rpt_personal_information", acViewPreview, , "[PIDDD] = " & [ExistentID]
when i click yes the report should open with the existent id but he open a input box to ente an id and his title is tbl_personal_information.PID it's the ID field that it's named P_ID in the query
i have a form to enter a new client if the client is existed then a message box appear and tell me that this client is existed and his number id is ## with two buttons yes and no
if i click yes i should go to a report that contains information about that user
and this report take his data from a query
new client save code
---------------------
Dim MSG As Integer
Dim ExistentID As Long
ExistentID = Nz(DLookup("P_ID", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N"), 0)
If ExistentID > 0 Then
'--------------------------
MSG1 = MsgBox("this client is existed and his id number is {" & [ExistentID] & "}, do you want to see his information ", vbYesNo + vbQuestion + vbMsgBoxRtlReading, "client database")
If MSG1 = vbYes Then
DoCmd.OpenReport "rpt_personal_information", acViewPreview, , "[PIDDD] = " & [ExistentID]
Else
End If
Else
strsql101 = "insert into tbl_Personal_Information (Name_English, Father_English, Family_English, Mother_English, P_ID, NName, Father, Family, Mother, Birthdate, Nationality, Record_Number, Record_Place, Address, Mobile1, Mobile2, Phone1, Phone2, Ets_Name) Values ('" & Me.Name_English & "','" & Me.Father_English & "','" & Me.Family_English & "','" & Me.Mother_English & "','" & Me.PID & "','" & Me.NName & "','" & Me.Father & "','" & Me.Family & "','" & Me.Mother & "','" & Me.Birthdate & "','" & Me.Nationality & "','" & Me.Record_Number & "','" & Me.Record_Place & "','" & Me.Address & "','" & Me.Mobile_1 & "', '" & Me.Mobile_2 & "','" & Me.Phone_1 & "', '" & Me.Phone_2 & "','" & Me.Ets_Name & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql101
'--------------------------
MSG2 = MsgBox("information added succesfully, do you want to add a new record", vbYesNo + vbQuestion + vbMsgBoxRtlReading, "client database")
If MSG2 = vbYes Then
DoCmd.Close acForm, "frm_New_Person"
DoCmd.OpenForm "frm_New_Person"
Else
DoCmd.OpenForm "frm_Entering_Data"
DoCmd.Close acForm, "frm_New_Person"
End If
End If
note that PIDDD is a textbox in the report that it's bounded with P_ID in the query
my problem is this line
DoCmd.OpenReport "rpt_personal_information", acViewPreview, , "[PIDDD] = " & [ExistentID]
when i click yes the report should open with the existent id but he open a input box to ente an id and his title is tbl_personal_information.PID it's the ID field that it's named P_ID in the query