B
Bird Byte
I have a list box on form 1 that populates when the form opens. When someone
clicks on an item, form 2 opens with text boxes filled with info dependent on
the record that was selected on form 1.
It only works for the first record. If any other record is selected error
2501 is generated (The OpenForm action was cancelled) behind form 1 and error
3164 (Field cannot be updated) behind form 2. MemberID is is an auto number
primary key in the Member table.
Code:
Form 1:
Private Sub Form_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Dim stSQL As String
stSQL = "SELECT Members.MemberID AS ID, Members.LName & ', ' +
Members!FName AS Name,iif(Contact![BestContact]='Home', [PhHome], [PhWork])AS
Phone FROM Members, Contact WHERE Members.MemberID = Contact.MemberID ORDER
BY Members.LName"
Set db = CurrentDb
Set rs = db.OpenRecordset(stSQL, dbOpenDynaset)
Me.lstMembers.RowSource = stSQL
Me.lstMembers.Requery
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Private Sub lstMembers_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmMember", , , "MemberID= '" & Me.lstMembers & "'", , ,
Me.lstMembers
End Sub
Form 2:
Private Sub Form_Load()
'If IsNull(Me.OpenArgs) Then
'programming Error
'Else
Me.MemberID = Me.OpenArgs
'End If
End Sub
I've tried with code behind form 2 and no code - it happens either way.
Thanks very much for any ideas.
clicks on an item, form 2 opens with text boxes filled with info dependent on
the record that was selected on form 1.
It only works for the first record. If any other record is selected error
2501 is generated (The OpenForm action was cancelled) behind form 1 and error
3164 (Field cannot be updated) behind form 2. MemberID is is an auto number
primary key in the Member table.
Code:
Form 1:
Private Sub Form_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Dim stSQL As String
stSQL = "SELECT Members.MemberID AS ID, Members.LName & ', ' +
Members!FName AS Name,iif(Contact![BestContact]='Home', [PhHome], [PhWork])AS
Phone FROM Members, Contact WHERE Members.MemberID = Contact.MemberID ORDER
BY Members.LName"
Set db = CurrentDb
Set rs = db.OpenRecordset(stSQL, dbOpenDynaset)
Me.lstMembers.RowSource = stSQL
Me.lstMembers.Requery
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Private Sub lstMembers_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmMember", , , "MemberID= '" & Me.lstMembers & "'", , ,
Me.lstMembers
End Sub
Form 2:
Private Sub Form_Load()
'If IsNull(Me.OpenArgs) Then
'programming Error
'Else
Me.MemberID = Me.OpenArgs
'End If
End Sub
I've tried with code behind form 2 and no code - it happens either way.
Thanks very much for any ideas.