BookMark problem

C

CF

I am hoping someone could shed some light of what I am
doing wrong.
I have a form which allows the user to make some changes
and allows them to open another form to make further
changes. The link between the 2 forms works fine.
However, I am not able to populate the form with the
customers information to allow the user to make changes.
Any help would be much appreciated.
code for first form:

Private Sub chgAttr_Click()
On Error GoTo Err_chgAttr_Click
Dim UPI As String
If IsNull(Me.txtNUPI) = False Then
UPI = Me.txtNUPI
Else
UPI = Me.txtUPI
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmStudentInfo"

stLinkCriteria = "[txtID]='" & UPI & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_chgAttr_Click:
Exit Sub

Err_chgAttr_Click:
MsgBox Err.Description
Resume Exit_chgAttr_Click

End Sub

code for second form:

Private Sub Form_Open(Cancel As Integer)

If IsNull(Me.txtID) Then
Else
If Forms!frmModify.Visible Then
Dim dbs As Database
Dim rst As Recordset
Dim rst2 As Recordset
Dim strSearchName As String
Dim Id As String
DataEntry = False

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblSTudentData")

Set rst2 = Me.RecordsetClone

strSearchName = Me.txtID

rst2.FindFirst "UPI = '" & strSearchName & "'"
If rst2.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst2.Bookmark
End If
End If
End If
End Sub
 
K

Ken Snell [MVP]

You may be seeing a timing problem in the second form. The Open event occurs
very early in the establishment of the form, and usually the controls and
data are not available until the Load event. Move your second form's Open
code to its Load event procedure instead and see if that works for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top