Add a button on the first Form
dont use the txt_change in that way, it will be triggerd every time the user enters a letter. SO if he wants to write "azifa" the change will be triggerd with evry letter he/she typs and will get an Msgbox, verry anoying
OK in the button_click
you set the code
Private Sub button1_click()
dim sql as string
me.DataField.recordsource = "Select * from TABLENAME " & _
" WHERE oprid LIKE " & me.txtOprID.text
' PS. if oprid is a number (1256)wich i hope it issn't use = instead of LIKE
' if oprid is in textvalue so "Hello" better to use LIKE instead of =
me.DataField.refresh
if me.DataField.recordset.recorcount <=0 then
msgbox "Sorry there seems to be an error", vbokonly+vbcritical,"No current record"
exit sub
else
If me.txtOprID.text=me.DataField.recordset("oprid") then
Form1.Hide
Form2.Show
Else
Msgbox "You are not allowed to access the form", vbokonly+vbcritical,"Access Denid"
End If
End If
End Sub
in the form load of frm2
you set
Privat Form2_load
with me
.txtOprID.text = Form1.DataField.recordset("oprid")
.txtID.text = Form1.DataField.recordset("ID")
.txtOprID.enabled = false
.txtID.enabled = false
end with
end sub