LeLeBrown
asked on
MS Access forms - passing data
I have two forms in Access 2007. I call one form using docmd and pass a variable from the list box on the first form. I then need to use that data in the second form. I have tried using it in the open and load events of the form but get invalid use of null. When I navigate to the form without putting this statement in, I see the variable value that I pass on the form. Why can't I use it in code when the form first loads/opens?
Thanks
Lisa
Thanks
Lisa
ASKER
Private Sub Form_Open(Cancel As Integer)
Dim cd As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim GrantNo As String
GrantNo = Me.txtGrantLevelGrantNumbe r <========= Error here because the form text field has not been populated yet.
Set cd = CurrentDb
strSql = "select * from GrantNumbersWithRemovalInd icator where GrantNumber = '" & GrantNo & " ' "
Set rs = cd.OpenRecordset(strSql)
Me.txtGrantLevelComments.V alue = rs!Comments
End Sub
Dim cd As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim GrantNo As String
GrantNo = Me.txtGrantLevelGrantNumbe
Set cd = CurrentDb
strSql = "select * from GrantNumbersWithRemovalInd
Set rs = cd.OpenRecordset(strSql)
Me.txtGrantLevelComments.V
End Sub
ASKER
forgot to post code to go to second form. it is just too lines of code:
Private Sub cmdSelect_Click()
DoCmd.OpenForm "GrantLevelCommentsRemoval s"
Forms!GrantLevelCommentsRe movals!txt GrantLevel GrantNumbe r = Me.List2.Value
End Sub
Private Sub cmdSelect_Click()
DoCmd.OpenForm "GrantLevelCommentsRemoval
Forms!GrantLevelCommentsRe
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No problem, you fixed it before I got back to my PC!
ASKER
I had the statement incorrect and it was a easy fix.
Could you post the code that's giving the error?
Thanks
John