Passing parameter in forms

F

Fiachra

Hi

I bascially want the user to login using an Inumber and password, from this
I look up the user table and find there name, Iam trying to pass this on to
the add session form so the the text field on this form will be already
filled with this name,
However at the moment I keep getting runtime error 2135 this property is
read only and cannot be set

login form code
Status = "X"
GBL_Status = Nz(DLookup("Status", "ServicePrep", "INumber='" &
Nz(Me.INumber, " ") & "' and Password='" & Nz(Me.Password, " ") & "'"), "X")
If GBL_Status = "X" Then
MsgBox "Invalid Username or Password... try again."
Me.INumber = ""
Me.Password = ""
Exit Sub
End If

Status = "Y"
GBL_Name = Nz(DLookup("Name", "ServicePrep", "INumber='" & Nz(Me.INumber, "
") & "' and Password='" & Nz(Me.Password, " ") & "'"), "Y")


Case "Prep"
stDocName = "Add Session"
stLinkCriteria = "[GBL_Name] = " & GBL_Name
DoCmd.OpenForm stDocName, , , , , , GBL_Name
Me.Visible = False
End Select


add session code

Private Sub Add_Click()
On Error GoTo Err_Add_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Click:
Exit Sub

Err_Add_Click:
MsgBox Err.Description
Resume Exit_Add_Click

End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click


DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub Form_Load()
Me.[Name] = Me.OpenArgs
MsgBox Name
End Sub

Any help with this would be appreciated,

Thanks
 
M

Mr B

Fiachra,

Assuming that your variable "GBL_Name" is a string type variable, try
changing your code where the variable "stLinkCriteria" is being assigned to:

stLinkCriteria = "[GBL_Name] = '" & GBL_Name & "'"

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com
 
F

Fiachra

Hi Mr B

I tried changing it like below but Iam still getting the sam error, any
other suggestions,

Thanks

Mr B said:
Fiachra,

Assuming that your variable "GBL_Name" is a string type variable, try
changing your code where the variable "stLinkCriteria" is being assigned to:

stLinkCriteria = "[GBL_Name] = '" & GBL_Name & "'"

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com


Fiachra said:
Hi

I bascially want the user to login using an Inumber and password, from this
I look up the user table and find there name, Iam trying to pass this on to
the add session form so the the text field on this form will be already
filled with this name,
However at the moment I keep getting runtime error 2135 this property is
read only and cannot be set

login form code
Status = "X"
GBL_Status = Nz(DLookup("Status", "ServicePrep", "INumber='" &
Nz(Me.INumber, " ") & "' and Password='" & Nz(Me.Password, " ") & "'"), "X")
If GBL_Status = "X" Then
MsgBox "Invalid Username or Password... try again."
Me.INumber = ""
Me.Password = ""
Exit Sub
End If

Status = "Y"
GBL_Name = Nz(DLookup("Name", "ServicePrep", "INumber='" & Nz(Me.INumber, "
") & "' and Password='" & Nz(Me.Password, " ") & "'"), "Y")


Case "Prep"
stDocName = "Add Session"
stLinkCriteria = "[GBL_Name] = " & GBL_Name
DoCmd.OpenForm stDocName, , , , , , GBL_Name
Me.Visible = False
End Select


add session code

Private Sub Add_Click()
On Error GoTo Err_Add_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Click:
Exit Sub

Err_Add_Click:
MsgBox Err.Description
Resume Exit_Add_Click

End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click


DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub Form_Load()
Me.[Name] = Me.OpenArgs
MsgBox Name
End Sub

Any help with this would be appreciated,

Thanks
 
M

Mr B

Fiachra,

I just noticed a line with Case "Prep".

Is this part of a Select Case Statement?

If so, you need to post all of the code. If not, then this could be your
problem. I do not see the Select Case or the End Select statements that
define a Select Case statetment.

What is the Case "Prep" line susposed to do?
--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com


Fiachra said:
Hi Mr B

I tried changing it like below but Iam still getting the sam error, any
other suggestions,

Thanks

Mr B said:
Fiachra,

Assuming that your variable "GBL_Name" is a string type variable, try
changing your code where the variable "stLinkCriteria" is being assigned to:

stLinkCriteria = "[GBL_Name] = '" & GBL_Name & "'"

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com


Fiachra said:
Hi

I bascially want the user to login using an Inumber and password, from this
I look up the user table and find there name, Iam trying to pass this on to
the add session form so the the text field on this form will be already
filled with this name,
However at the moment I keep getting runtime error 2135 this property is
read only and cannot be set

login form code
Status = "X"
GBL_Status = Nz(DLookup("Status", "ServicePrep", "INumber='" &
Nz(Me.INumber, " ") & "' and Password='" & Nz(Me.Password, " ") & "'"), "X")
If GBL_Status = "X" Then
MsgBox "Invalid Username or Password... try again."
Me.INumber = ""
Me.Password = ""
Exit Sub
End If

Status = "Y"
GBL_Name = Nz(DLookup("Name", "ServicePrep", "INumber='" & Nz(Me.INumber, "
") & "' and Password='" & Nz(Me.Password, " ") & "'"), "Y")


Case "Prep"
stDocName = "Add Session"
stLinkCriteria = "[GBL_Name] = " & GBL_Name
DoCmd.OpenForm stDocName, , , , , , GBL_Name
Me.Visible = False
End Select


add session code

Private Sub Add_Click()
On Error GoTo Err_Add_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Click:
Exit Sub

Err_Add_Click:
MsgBox Err.Description
Resume Exit_Add_Click

End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click


DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub Form_Load()
Me.[Name] = Me.OpenArgs
MsgBox Name
End Sub

Any help with this would be appreciated,

Thanks
 

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