Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 2nd, 2007, 01:01 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to resolve #Name? Error problem in few fields

Hi,
I am calling a stored procedure from an Access unbound form.I made sure that the control source of the unbound form is named in accordance with the output of the stored procedure. However, in some of the fields instead of getting proper value I am getting #Name? in the data. I am not sure exactly why the values are not being displayed. Is it the stored procedure parameter setting incorrect or something else. Still a puzzle. Any help is appreciate. Thanks

CODE TO CALL STORED PROCEDURE:

Private Sub Form_Load()

'To make all the fields visible

'MarketChannel.Visible = True
'TBSGroup.Visible = True
'Amount.Visible = True
'GLPeriod.Visible = True
'GLYear.Visible = True


Dim cmdSelect As ADODB.Command
Dim strMarketChannel As String
Dim strTBSGroup As String
Dim strAmount As String
Dim strGLPeriod As String
Dim strGLYear As String
Dim curAmount As Currency
 Set conn = New ADODB.Connection
 Set cmdSelect = New ADODB.Command

 conn.Provider = "SQLOLEDB"

' conn.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=pubs;Data Source=localhost;User ID=sa;Password=1CdoBn98;"
conn.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=TBS;Data Source=USILDEK1-21001;User ID=sa;Password=test;"
 conn.CursorLocation = adUseClient
 conn.Open

'Code added

cmdSelect.CommandType = adCmdStoredProc
cmdSelect.CommandText = "sp_select_data"
Set cmdSelect.ActiveConnection = conn

  ' Get the form values
  strMarketChannel = Forms!frmSearchRecords!cboBusinessUnit
  strTBSGroup = Forms!frmSearchRecords!cboTbsGroup
  strGLPeriod = Forms!frmSearchRecords!cboGLPeriod
  strGLYear = Forms!frmSearchRecords!cboTBSYear

  strTBSGroup1 = Val(strTBSGroup)
  strGLPeriod1 = Val(strGLPeriod)
  strGLYear1 = Val(strGLYear)

   MsgBox ("Procedure complete. Records selected" & vbCrLf & _
 "Parameter 1: " & strMarketChannel & vbCrLf & "Parameter 2: " & strTBSGroup & vbCrLf & "Parameter 3: " & strGLPeriod & vbCrLf & "Parameter 4: " & strGLYear)


   ' Add the parameters
    cmdSelect.Parameters.Append cmdSelect.CreateParameter("@businessunit", adVarWChar, adParamInput, 1, strMarketChannel)
    cmdSelect.Parameters.Append cmdSelect.CreateParameter("@tbsgroup", adInteger, adParamInput, 8, strTBSGroup1)
    cmdSelect.Parameters.Append cmdSelect.CreateParameter("@glperiod", adInteger, adParamInput, 8, strGLPeriod1)
    cmdSelect.Parameters.Append cmdSelect.CreateParameter("@tbsyear", adInteger, adParamInput, 8, strGLYear1)
    'cmdSelect.Parameters.Append cmdSelect.CreateParameter("@Percent", adCurrency, adParamInput, , curPercent1)



   ' Execute the command
 Set rs = cmdSelect.Execute


 Set Me.Recordset = rs



End Sub

CODE FOR STORED PROCEDURE:

CREATE procedure sp_select_data
@businessunit char(1),
@tbsgroup int,
@glperiod int,
@tbsyear int
AS
select MktChannel, [TBS Grp], Amount, [GL Per], [GL Yr] from tblTBS
where
MktChannel = @businessunit and
[TBS Grp] = @tbsgroup and
[GL Per] = @glperiod and
[GL Yr] = @tbsyear
GO
Reply With Quote
  #2 (permalink)  
Old August 2nd, 2007, 02:08 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind folks. Problems solved. I was not looking carefully enough in the fields where two of those were mismatch with the output from stored procedure. Thanks anyway.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
soapenv:Client - Error: Could not resolve to an op crmpicco XML 7 November 12th, 2008 01:18 PM
Need help to Resolve Error ORA-00933 sandeepshivathaya Oracle 0 August 19th, 2004 07:15 AM
Error-cannot resolve symbol Rusk JSP Basics 1 February 18th, 2004 09:20 AM
cannot resolve symbol problem ioda006 JSP Basics 2 July 28th, 2003 06:04 AM
Error: Cannot resolve symbol "Beginning JSP" amcp2002 Wrox Book Feedback 2 July 22nd, 2003 03:30 PM



All times are GMT -4. The time now is 09:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.