PC Review


Reply
Thread Tools Rate Thread

Can't call a subprocedure even when it's Public

 
 
EAB1977
Guest
Posts: n/a
 
      15th Jan 2008
Hi guys,

I have a form where users input data into a form. I created another
form, using a listbox, to show the user some of the data that is
already entered (RecordID, date, person, print name is all). I did it
this way because there was no room on my input form to place the
listbox.

Anyway, when I select a item in my listbox to see what the user
entered in the for a particular entry, I get a compile error: variable
not defined. Here is my code:

Private Sub btnViewData_Click()
On Error GoTo Err_btnViewData_Click

frmAnalysis2.ViewExistingData

Exit_btnViewData_Click:
Exit Sub

Err_btnViewData_Click:
MsgBox Err.Description
Resume Exit_btnViewData_Click
End Sub

---------------------------------------------------------------

Public Sub ViewExistingData()

Dim db As DAO.Database, rstData As DAO.Recordset, rstPlant As
DAO.Recordset
Dim rstPrint As DAO.Recordset, frm As Form

On Error GoTo ErrorHandler
Set db = CurrentDb
Set rstData = db.OpenRecordset("SELECT * FROM tblData WHERE
tblData.RecordID = " & Forms!frmExistingData!
lstExistingData.Column(0))

Set rstPlant = db.OpenRecordset("SELECT dbo_Plant.Name FROM dbo_Plant
INNER JOIN tblData" _
& " ON dbo_Plant.Code = tblData.Plant
WHERE tblData.RecordID = " _
& Forms!frmExistingData!
lstExistingData.Column(0))

Set rstPrint = db.OpenRecordset("SELECT
dbo_vwProductPlateAttribute.LLDSCP FROM tblData INNER JOIN" _
& " dbo_vwProductPlateAttribute ON tblData.
[Print Name] =" _
& " dbo_vwProductPlateAttribute.LLUPRD
WHERE tblData.RecordID = " & Forms!frmExistingData!
lstExistingData.Column(0))

Set frm = Forms!frmAnalysis2

With rstData
Stop
Me.datDate.Value = !Date
Me.datWeekEndDate.Value = !WeekEndDate
Me.cboPlant.Value = rstPlant!Name
Me.cboProdCode.Value = ![Product Code]
Me.cboPrintName.Value = rstPrint!LLDSCP
Me.txtPrinterNum.Value = ![Printer Number]
Me.txtPrintAlert.Value = ![Print Alert]
Me.txtTotalInsp.Value = ![Total Inspections]
Me.txtCupQuality.Value = ![Cup Quality]
Me.txtWetInk.Value = ![Wet Ink Ink Inside]
Me.txtHgtLapGap.Value = ![Height Gap Lap]
Me.txtColor.Value = !Color
Me.txtColorVar.Value = ![Color Variation]
Me.txtSmearing.Value = !Smearing
Me.txtBuildup.Value = !Buildup
Me.txtSpeckling.Value = !Speckling
Me.txtBlanketMarks.Value = ![Blanket Marks]
Me.txtRegister.Value = !Register
Me.txtInkOutside.Value = ![Ink Outside of Print Area]
Me.txtBeadBlanket.Value = ![Bead on Blanket]
Me.txtOther.Value = !Other
Me.txtGhosting.Value = !Ghosting
Me.txtMissingPrint.Value = ![Missing Print]
Me.txtWaterSpots.Value = ![Water Spots]
Me.txtScaling.Value = !Scaling
Me.txtFillingIn.Value = ![Filling In]
Me.txtWrongColor.Value = ![Wrong Color]
Me.txtUVPostExp.Value = ![UV Post Expansion]
Me.txtComments.Value = !Comments
Me.txtCaseCount.Value = ![Case Count]
Me.txtSleeveCount.Value = ![Sleeve Count]
Me.txtCaseCodeID.Value = ![Case Code ID]
End With

ErrorHandler_Exit:
Set rstPlant = Nothing
Set rstData = Nothing
Set rstPrint = Nothing
Set db = Nothing
Exit Sub

ErrorHandler:
MsgBox Err.Description, , "Error " & Err.Number
Resume ErrorHandler_Exit

End Sub
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      15th Jan 2008
"EAB1977" <(E-Mail Removed)> wrote in message
news:9e8975d1-40ea-42ee-87f0-(E-Mail Removed)...
> Hi guys,
>
> I have a form where users input data into a form. I created another
> form, using a listbox, to show the user some of the data that is
> already entered (RecordID, date, person, print name is all). I did it
> this way because there was no room on my input form to place the
> listbox.
>
> Anyway, when I select a item in my listbox to see what the user
> entered in the for a particular entry, I get a compile error: variable
> not defined. Here is my code:
>
> Private Sub btnViewData_Click()
> On Error GoTo Err_btnViewData_Click
>
> frmAnalysis2.ViewExistingData
>
> Exit_btnViewData_Click:
> Exit Sub
>
> Err_btnViewData_Click:
> MsgBox Err.Description
> Resume Exit_btnViewData_Click
> End Sub
>
> ---------------------------------------------------------------
>
> Public Sub ViewExistingData()
>
> Dim db As DAO.Database, rstData As DAO.Recordset, rstPlant As
> DAO.Recordset
> Dim rstPrint As DAO.Recordset, frm As Form
>
> On Error GoTo ErrorHandler
> Set db = CurrentDb
> Set rstData = db.OpenRecordset("SELECT * FROM tblData WHERE
> tblData.RecordID = " & Forms!frmExistingData!
> lstExistingData.Column(0))
>
> Set rstPlant = db.OpenRecordset("SELECT dbo_Plant.Name FROM dbo_Plant
> INNER JOIN tblData" _
> & " ON dbo_Plant.Code = tblData.Plant
> WHERE tblData.RecordID = " _
> & Forms!frmExistingData!
> lstExistingData.Column(0))
>
> Set rstPrint = db.OpenRecordset("SELECT
> dbo_vwProductPlateAttribute.LLDSCP FROM tblData INNER JOIN" _
> & " dbo_vwProductPlateAttribute ON tblData.
> [Print Name] =" _
> & " dbo_vwProductPlateAttribute.LLUPRD
> WHERE tblData.RecordID = " & Forms!frmExistingData!
> lstExistingData.Column(0))
>
> Set frm = Forms!frmAnalysis2
>
> With rstData
> Stop
> Me.datDate.Value = !Date
> Me.datWeekEndDate.Value = !WeekEndDate
> Me.cboPlant.Value = rstPlant!Name
> Me.cboProdCode.Value = ![Product Code]
> Me.cboPrintName.Value = rstPrint!LLDSCP
> Me.txtPrinterNum.Value = ![Printer Number]
> Me.txtPrintAlert.Value = ![Print Alert]
> Me.txtTotalInsp.Value = ![Total Inspections]
> Me.txtCupQuality.Value = ![Cup Quality]
> Me.txtWetInk.Value = ![Wet Ink Ink Inside]
> Me.txtHgtLapGap.Value = ![Height Gap Lap]
> Me.txtColor.Value = !Color
> Me.txtColorVar.Value = ![Color Variation]
> Me.txtSmearing.Value = !Smearing
> Me.txtBuildup.Value = !Buildup
> Me.txtSpeckling.Value = !Speckling
> Me.txtBlanketMarks.Value = ![Blanket Marks]
> Me.txtRegister.Value = !Register
> Me.txtInkOutside.Value = ![Ink Outside of Print Area]
> Me.txtBeadBlanket.Value = ![Bead on Blanket]
> Me.txtOther.Value = !Other
> Me.txtGhosting.Value = !Ghosting
> Me.txtMissingPrint.Value = ![Missing Print]
> Me.txtWaterSpots.Value = ![Water Spots]
> Me.txtScaling.Value = !Scaling
> Me.txtFillingIn.Value = ![Filling In]
> Me.txtWrongColor.Value = ![Wrong Color]
> Me.txtUVPostExp.Value = ![UV Post Expansion]
> Me.txtComments.Value = !Comments
> Me.txtCaseCount.Value = ![Case Count]
> Me.txtSleeveCount.Value = ![Sleeve Count]
> Me.txtCaseCodeID.Value = ![Case Code ID]
> End With
>
> ErrorHandler_Exit:
> Set rstPlant = Nothing
> Set rstData = Nothing
> Set rstPrint = Nothing
> Set db = Nothing
> Exit Sub
>
> ErrorHandler:
> MsgBox Err.Description, , "Error " & Err.Number
> Resume ErrorHandler_Exit
>
> End Sub



It's a little hard for me to tell which block of code is on which form, and
which form is which. perhaps you could clarifyt that? But this line of
code:

> frmAnalysis2.ViewExistingData


in btnViewData_Click() doesn't show any indication that "frmAnalysis2" is a
variable that is defined and set anywhere. Did you mean it to be a direct
form reference, in which case it should have been like this:

Forms!frmAnalysis2.ViewExistingData

?

Also, in your ViewExistingData() procedure, I see this line setting a Form
object variable:

> Set frm = Forms!frmAnalysis2


But I don't see anywhere that variable is used. That wouldn't cause an
error, but it seems pointless.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing an Array created in a Function or Subprocedure back to the calling Subprocedure Cloudfall Microsoft Excel Discussion 7 17th Mar 2006 12:56 AM
VBA code: call subprocedure Terry Microsoft Excel Programming 5 14th Dec 2005 04:49 AM
how to call subprocedure from within procedure? dreamz Microsoft Excel Programming 26 1st Nov 2005 06:38 PM
Public Function to call private (public) sub? =?Utf-8?B?SkhL?= Microsoft Access VBA Modules 7 19th Jun 2005 02:43 PM
Convert Subprocedure into Public Module Tom \T\ Microsoft Access VBA Modules 6 6th Jan 2004 02:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:35 AM.