Log in Register FAQ Memberlist Search ContactReview Forum Index
A GoldMine Discussion and Support Community

ContactReview Forum Index » GoldMine Coders » VB6 and DDE
Post new topic  Reply to topic View previous topic :: View next topic 
VB6 and DDE
PostPosted: Fri Sep 25, 2009 12:11 pm Points: 0 Reply with quote
vb6guy
n00b
Joined: 25 Sep 2009
Posts: 6




I have downloaded all the Goldmine information on using DDE from FRS and Doug Castell's post and loaded it into my VB6 project. What I have loaded is below. I know this is an old topic but I am not familar with DDE

-------------------------------------------------
Public Function DDERequest(sExpr As String) As String

With txtGMDDE
.LinkItem = sExpr
.LinkRequest
DDERequest = .Text
End With

End Function
Public Function DDEInitiate() As Integer

On Error GoTo Err_DDE

With txtGMDDE
.LinkMode = vbLinkNone
.LinkTopic = "GoldMine|Data"
.LinkMode = vbLinkManual
End With

DDEInitiate = 1
Exit Function

Err_DDE:
If Err = 282 Then
MsgBox "GoldMine is not running! Please launch GoldMine before attempting " & _
"to run this operation.", vbCritical, "DDE Error"
End
Else
Err.Description = "DDE Error:" & Err & " :" & Err.Description
End If

DDEInitiate = 0
End Function
-------------------------------------------------

What I need to know is 1) how to rework the code below to select the current recid (instead of the Sysdir, GoldDir, CommonDir) and 2) how to integrate the recid into my VB6 code - would I just Dim a variable and assign the value returned by DDE? Then use that variable to constrain my Goldmine select statement (select * from Contact1 where recid=dderecid?)

With frmDDE
iReturn = .DDEInitiate
If iReturn Then
sGM_Sysdir = .DDERequest("&sysdir")
sGM_GoldDir = .DDERequest("&golddir")
sGM_Commondir = .DDERequest("&commondir")
End If
End With
-------------------------------------------------

Thanks
View user's profile Send private message

PostPosted: Fri Sep 25, 2009 12:54 pm Points: 0 Reply with quote
DougCastell
GoldMine Guru
Joined: 15 Jun 2006
Posts: 1631
Location: Los Angeles, CA




Code:
With frmDDE
iReturn = .DDEInitiate
If iReturn Then
sRedic= .DDERequest("contact1->Recid")
End If
End With


That ought to do it! Smile

_________________
Doug Castell

GoldMine Sales and Support:
http://www.castellcomputers.com/
office: (310)601-4738
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number

Follow up question
PostPosted: Fri Sep 25, 2009 2:29 pm Points: 0 Reply with quote
vb6guy
n00b
Joined: 25 Sep 2009
Posts: 6




Thanks Doug, for the quick response

One more question - where should I place this code in my project

1) in the frmDDE code
2) in the frmIns code (where my ADODB connection is made)

If in the code where I connect to Contact1, where would it be in reference to the connecton to Goldmine?

Let me know if you need any more details

Thanks again
View user's profile Send private message

PostPosted: Fri Sep 25, 2009 5:26 pm Points: 0 Reply with quote
DougCastell
GoldMine Guru
Joined: 15 Jun 2006
Posts: 1631
Location: Los Angeles, CA




Nope, all you need to do is place that WITH statement (like in my post, above) in whatever other area of your project and frmdde will take care of the rest of the dde request to GoldMine. Frances Corazza taught me this technique years ago and I've been using it ever since to read dde from GoldMine. Very handy.

_________________
Doug Castell

GoldMine Sales and Support:
http://www.castellcomputers.com/
office: (310)601-4738
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number

Still problems selecting Goldmine record with DDE sRedic
PostPosted: Sat Sep 26, 2009 5:19 pm Points: 0 Reply with quote
vb6guy
n00b
Joined: 25 Sep 2009
Posts: 6




Doug

First, thanks for all your help with this. Unfortunately I am not catching on to what I need to do (which I am sure is due to gaps in my knowledge). But perhaps if I explan what I need to do you can show what to change in my VB6 code

Also feel free to tell me when i have crossed the line into billable work and I will be glad to pay for your time.

What I am doing and why I need the recid:

1. Open a VB 6 form from the external application toolbar icon in Goldmine 8.5
(this works)

2. Read in all Contact1 values using a DSN via an ADODB connection
(this works)

3. Dim variables / populate them with Goldmine values from text boxes on the VB form
(this works)

4. Use the GM values in the variables to create a new contact in another, external database (not a Goldmine database) when I click a command button on the form
(this works)

What I need to do, however, is to limit the GM record that appears in the VB form by recid. Right now, all records appear and I need to scroll to the record I want to write to the second database. I want the record that is the current record in Goldmine to populate the VB form when I open it from the External Application toolbar icon.

I have tried a number of approaches and feel like I have reached the point where I am just using trial and error. I have included the code below.

Thanks again

Code:


'this is the command button code, dim variables and assignment of GM values

Private Sub cmdIns_Click()
On Error GoTo ErrorHandler

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "DSN=Goldmine;OLE DB Services=-2"

Dim asCompany(1)
Dim asContact(1)
Dim asFName(1)
Dim asLName(1)
Dim asBAddr1(1)
Dim asBAddr2(1)
Dim asBAddr3(1)
Dim asBCity(1)
Dim asBState(1)
Dim asBZip(1)
Dim asSAddr1(1)
Dim asSAddr2(1)
Dim asSAddr3(1)
Dim asSCity(1)
Dim asSState(1)
Dim asSZip(1)
Dim asPhone1(1)
Dim asPhone2(1)
Dim asEmail(1)
Dim sSQL
Dim lCnt
'***********************************
asCompany(1) = txtFields(1).Text
asContact(1) = txtFields(2).Text
asFName(1) = txtFields(22).Text
asLName(1) = txtFields(3).Text
asBAddr1(1) = txtFields(15).Text
asBAddr2(1) = txtFields(16).Text
asBAddr3(1) = ""
asBCity(1) = txtFields(18).Text
asBState(1) = txtFields(19).Text
asBZip(1) = txtFields(20).Text
asPhone1(1) = txtFields(7).Text
asPhone2(1) = txtFields(8).Text
asEmail(1) = ""
'***********************************

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "DSN=QEM Data;OLE DB Services=-2"

For lCnt = 1 To UBound(asFName)
    sSQL = "SELECT * FROM Customer WHERE FirstName <> '" & asFName(lCnt) & "' and LastName <> '" & asLName(lCnt) & "' and CompanyName <> '" & asCompany(lCnt) & "'"
       
    Set oRecordset = CreateObject("ADODB.Recordset")
    oRecordset.CursorType = 2
    oRecordset.LockType = 3
    oRecordset.Open sSQL, oConnection
   
    With datPrimaryRS.Recordset
    .MoveLast
    End With
     
    If (Not oRecordset.EOF) Then
        oRecordset.AddNew
        oRecordset.Fields("Name").Value = asCompany(lCnt)
        oRecordset.Fields("FirstName").Value = asFName(lCnt)
        oRecordset.Fields("LastName").Value = asLName(lCnt)
        oRecordset.Fields("Contact").Value = asContact(lCnt)
        oRecordset.Fields("Phone").Value = asPhone1(lCnt)
        oRecordset.Fields("BillAddressCity").Value = asBCity(lCnt)
        oRecordset.Fields("BillAddressState").Value = asBState(lCnt)
        oRecordset.Fields("BillAddressPostalCode").Value = asBZip(lCnt)
        oRecordset.Fields("BillAddressAddr1").Value = asCompany(lCnt)
        oRecordset.Fields("CompanyName").Value = asCompany(lCnt)
        oRecordset.Fields("AltPhone").Value = asPhone2(lCnt)
        oRecordset.Update
        End If
Next
'***********************************
'oRecordset.Close
Set oRecordset = Nothing

oConnection.Close
Set oConnection = Nothing
'***********************************
End Sub
_____________________________________________________________________

Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
  'This is where you would put error handling code
  'If you want to ignore errors, comment out the next line
  'If you want to trap them, add code here to handle them
  MsgBox "Data error event hit err:" & Description
End Sub
_____________________________________________________________________

Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
  'This will display the current record position for this recordset
  datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub
_____________________________________________________________________

Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
  'This is where you put validation code
  'This event gets called when the following actions occur
  Dim bCancel As Boolean

  Select Case adReason
  Case adRsnAddNew
  Case adRsnClose
  Case adRsnDelete
  Case adRsnFirstChange
  Case adRsnMove
  Case adRsnRequery
  Case adRsnResynch
  Case adRsnUndoAddNew
  Case adRsnUndoDelete
  Case adRsnUndoUpdate
  Case adRsnUpdate
  End Select

  If bCancel Then adStatus = adStatusCancel
End Sub
_____________________________________________________________________

Private Sub cmdClose_Click()
  Unload Me
End Sub

View user's profile Send private message

PostPosted: Mon Sep 28, 2009 11:02 am Points: 0 Reply with quote
DougCastell
GoldMine Guru
Joined: 15 Jun 2006
Posts: 1631
Location: Los Angeles, CA




Check out my downloads page for a sample VB6 project that ought to help out.

Direct link: http://www.castellcomputers.com/files/frmdde_vb6_example.zip

_________________
Doug Castell

GoldMine Sales and Support:
http://www.castellcomputers.com/
office: (310)601-4738
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number

VB6 and DDE
  ContactReview Forum Index » GoldMine Coders
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 7 Hours  
Page 1 of 1  

  
  
 Post new topic  Reply to topic  


Brought to you by Castell Computers, Doug Castell, Admin
RSS Feed
Powered by phpBB © 2001-2004 phpBB Group
Theme created by Vjacheslav Trushkin