By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

I am being asked for a value when I don't want to ....

P: n/a
Hello all,
I have defined a public variable at module level :
Public sSchrijver As String

Then, in the first form's combobox I assign a value to it :
Private Sub Kiesschrijver_Change()
If IsNull(Me!Kiesschrijver.Value) Then
sSchrijver = ""
Else
sSchrijver = Nz(Trim(Me!Kiesschrijver.Value))
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSchrijfbrief"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub
Then, when the second form (frmSchrijfbrief) opens, I define this form's
recordsource like this :

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "select * from tblMwerkers where volledigenaam =
sSchrijver"
End Sub

When running the whole thing I am being asked for a value for sSchrijver,
like when you run a parameter query, although the value for sSchrijver has
already been defined in the Kiesschrijver_Change() event ....

Can somebody tell me what I am doing wrong ?

Any help very much appreciated !
Thanks
Ronny Sigo

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Ronny Sigo" <ro********@skynet.be> wrote in message
news:3f**********************@reader2.news.skynet. be...
Hello all,
I have defined a public variable at module level :
Public sSchrijver As String

Then, in the first form's combobox I assign a value to it :
Private Sub Kiesschrijver_Change()
If IsNull(Me!Kiesschrijver.Value) Then
sSchrijver = ""
Else
sSchrijver = Nz(Trim(Me!Kiesschrijver.Value))
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSchrijfbrief"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub
Then, when the second form (frmSchrijfbrief) opens, I define this form's
recordsource like this :

Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "select * from tblMwerkers where volledigenaam =
sSchrijver"
End Sub

When running the whole thing I am being asked for a value for sSchrijver,
like when you run a parameter query, although the value for sSchrijver has
already been defined in the Kiesschrijver_Change() event ....

Can somebody tell me what I am doing wrong ?

Any help very much appreciated !
Thanks
Ronny Sigo

sSchrijver is a string so you need quotes around it.
Try this:

Private Sub Form_Open(Cancel As Integer)

Dim strSQL As String

strSQL = "select * from tblMwerkers where volledigenaam="""
strSQL = strSQL & sSchrijver & """"

Me.RecordSource = strSQL

End Sub


Nov 12 '05 #2

P: n/a
Ronny,
Public sSchrijver As String
For this operation you don't need sSchrijver.

Private Sub Kiesschrijver_Change()
Dim stDocName As String
Dim stLinkCriteria As String
If Nz(Me!Kiesschrijver.Value,"") <>"" Then
stDocName = "frmSchrijfbrief"
stLinkCriteria = "volledigenaam = '" & _
Me!Kiesschrijver.Value & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "select * from tblMwerkers where volledigenaam =
sSchrijver"
End Sub


Remove these lines.

HTH - Peter

--
No mails please.
Nov 12 '05 #3

P: n/a
Thanks guys :)

"Ronny Sigo" <ro********@skynet.be> wrote in message
news:3f**********************@reader2.news.skynet. be...
Hello all,
I have defined a public variable at module level :
Public sSchrijver As String


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.