Results 1 to 3 of 3
  1. #1
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085

    ReplicationID Reference in VBA

    I have a linked SQL Server Database that uses a guid as one of the keys in an Access 2010 DB. I need to write a function that takes the guid as a parameter. Runs a query that sums a numeric field and returns that sum to the query. What I can't figure out is how do I set the Parameter Type to ReplicationID? If I import a portion of the table Access defines the field as ReplicationID but when I put ReplicationID in the code it errors?

    Public Function Member_Mnths(ByRef PCPKey As ????) As Long


    Dim strsql As String, rs As New ADODB.Recordset
    strsql = "SELECT Sum(a.CURRMM) AS MM " & _
    "FROM dbo_RVS_CAP_MM_HIST a INNER JOIN tbl_HPCODEs ON a.HPCODE = tbl_HPCODEs.HPCODE " & _
    "Where a.pcp_keyid = " & PCPKey & " AND CVDate(a.capmonth & " / 1 / " & a.capyear) between #" & _
    DateAdd("m", -7, CVDate(Month(Now()) & "/01/" & Year(Now()))) & "# AND #" & DateAdd("d", -1, DataAdd("m", -1, CVDate(Month(Now()) & "/01/" & Year(Now())))) & _
    "# "
    rs.Open strsql, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
    If rs.EOF Then Member_Mnths = 0 Else Member_Mnths = rs!MM
    rs.Close
    Set rs = Nothing


    End Function

  2. #2
    Estuardo's Avatar
    Estuardo is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Portugal
    Posts
    22
    G'd evening Ray,
    First of. Please don't use GUI's for any of your programming needs. As you notice it is (in our ms-sql/access world) just for replication. As a rule of thumb don't use them, let the db engines do.
    That being said. What you're looking at is not the "real" value, what you see is the canonical value and it will change as soon as you change any row. You should not manipulate that value. if you really need to see i'll dare to say that you may try with the access functions StringFromGUID and GUIDFromString. Once again i'm not sure if this will help.
    If you can, add a natural key or any other key to your tables to make easier the data manipulation.
    G'd luck

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    Unfortunately there are no local tables. This particular Access Database is used for Reporting from a SQL Server Database.

    The Report does several calculations and one of the divisors in the calculation is member months. This function is to return the number of Member Months for a 6 month period. The full calculation is (a/pcpmembermonths) * ( reporting period in days /365 ) * 1000 (although I can never remember off the top of my head if its reporting period in days/365 or the other way around.) I have the formula on my desk so I don't have to remember it but I'm not at work today.

    Since the report is for a specific PCP I have to use the PCP Key Id to get only the member months assigned to that PCP.

    I'll try that stringfromguid and guidfromstring. I knew about the stringfromguid but not the guidfromstring which is why mine kept failing. Thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Reference
    By joekuhn in forum Access
    Replies: 2
    Last Post: 06-17-2011, 08:38 PM
  2. How to Reference a text box in VBA
    By bogdan1245 in forum Forms
    Replies: 14
    Last Post: 04-26-2011, 05:30 PM
  3. Reference a text box in vba
    By forestgump in forum Forms
    Replies: 5
    Last Post: 04-25-2011, 08:55 AM
  4. need help with reference..
    By dada in forum Programming
    Replies: 3
    Last Post: 09-17-2010, 06:07 PM
  5. Reference to a Query
    By starhannes in forum Forms
    Replies: 5
    Last Post: 05-09-2010, 02:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums