Solved

Merge

Posted on 2009-06-30
2
311 Views
Last Modified: 2013-11-25
How to correct the code below wherein I want to merge  the two field in one table?
'Class mudule
Public Function Merged(ProCode As String) As String
Dim Merge(1 To 2) As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String
Set rs = New ADODB.Recordset
    sql = "select Top 1 Tag_Name,  Quantity from STOCK where PROCODE='" & ProCode & "'"
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    rs.Open sql, cn
    With rs
        If .BOF = True And _
            .EOF = True Then
            Merge(1) = ""
            Merge(2) = (0)
        Else
            Merge(1) = !Tag_Name & ""
            Merge(2) = !Quantity
        End If
        .Close
    End With
    Set rs = Nothing
End Function
 
'Form
Public Sub Tag1()
Dim s As Labeler
Set s = New Labeler
s.OPEN_CON "mydb", ""
Dim j As SSCommand
For Each j In cmd1
    j.Caption = s.Merge(1)(j.Index) & vbNewLine & s.Merge(2)(j.Index)
Next
s.CLOSE_CON
Set s = Nothing
End Sub

Open in new window

0
Comment
Question by:Whing Dela Cruz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 24750654
I really don't know what you are asking for. It is not really clear again!

One thing for sure is that Merge is a variable local to the Merged Function so it cannot be accessed outside it (and you try to do just that.

could you try this:

'Class mudule
PUBLIC Merge(1 To 2) As String
 
Public sub Merged(ProCode As String) 
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String
Set rs = New ADODB.Recordset
    sql = "select Top 1 Tag_Name,  Quantity from STOCK where PROCODE='" & ProCode & "'"
    rs.LockType = adLockOptimistic
    rs.CursorType = adOpenKeyset
    rs.Open sql, cn
    With rs
        If .BOF = True And _
            .EOF = True Then
            Merge(1) = ""
            Merge(2) = (0)
        Else
            Merge(1) = !Tag_Name & ""
            Merge(2) = !Quantity
        End If
        .Close
    End With
    Set rs = Nothing
End sub
 
'Form
Public Sub Tag1()
Dim s As Labeler
Set s = New Labeler
s.OPEN_CON "mydb", ""
Dim j As SSCommand
For Each j In cmd1
    call s.Merged(j.Index)
    j.Caption = s.Merge(1) & vbNewLine & s.Merge(2)
Next
s.CLOSE_CON
Set s = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 31598483
Thank you sir, Through this idea i was able to solve the problem..
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
transition to visual .net from vb6 5 81
Collapse and expand table in Word 2010 2 161
Assign a value in Excel V-Basic 3 38
Macro problems with Excel file 6 52
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question