Advice sought - which language to learn of these three....

peskywinnets

Registered User.
Local time
Today, 20:12
Joined
Feb 4, 2014
Messages
578
I run a small online retail business (husband + 'occasionally wife helping' team!). I presently use third party apps to help me manage my business (mainly apps that 'pull in' orders from various selling channels).

Quite often there isn't a tool that I need, which is frustrating. Indeed that's why I started learning/using Access, which has helped me massively (it plugs 'gaps' in the overall aspect of running a business) .....but several gaps remain.

So I now wish to move up a tier (albeit in baby steps) & start thinking about using Amazon's API (to pull in data from Amazon which will help me make business decisions), they have supporting API libraries in 3 languages...

PHP Client Library
C# Client Library
Java Client Library

....now I'm no programmer, I get by (I've coded PIC MCUs using Picbasic in the past & I can kludge my way though using a little bit of VBA).

So my question is...

Bearing in mind I want 'pull in' data from Amazon (which is in XML format)...ultimately to get the data into access & bearing in mind my limited programming history (you could almost say I'm coming to all languages fresh), which of the above would you recommend I start learning/using? (therefore least learning curve, most aligned with skills I've picked up with MS Access, easiest for 'handling XML' etc.)


Many thanks.

P.S. There are some who - allegedly - have managed to pull the data in from Amazon using http 'get' requests & then handling/processing the returned XML into Access....but I've read that VBA is not the best approach (I can post some related VBA code if it'd help anyone comment whether it's viable approach), so it's probably best to set off on the right foot?
 
Last edited:
I run businesses on Access only. All VBA. It runs Access, Excel, Word, project, outlook.
Learn VBA and you can make these tools do pretty much everything.
Then if you feel you're missing something, you now have the starting blocks to learn a new language.
 
To guide you, you really need to tell us why you want to learn a language. As of now, you seem to only want to be able to process XML. Thing is, XML is just a is just an encoding method and any language can handle it. So VBA would work.

Do you have any future aspirations for your coding? That would help guide your language choice more than this task.
 
To guide you, you really need to tell us why you want to learn a language. As of now, you seem to only want to be able to process XML. Thing is, XML is just a is just an encoding method and any language can handle it. So VBA would work.

Do you have any future aspirations for your coding? That would help guide your language choice more than this task.

I don't have any future aspirations for programming at all.... I'm of the 'if I have to learn it to get something done, then so be it'.

I realise XML is just a way of encapsulating data, but getting that data in the first place is my stumbling block. Let me explain.

Amazon sellers can pull their data back from Amazon using a massive URL, within the URL is merchant ID, Amazon site ID, the data set required (e.g 'GetOrder').....once the massive URL is created, it needs to be SHA-2 'signed'. I found some VBA code on the net to 'sign' a URL, but it was created for Excel & I've not managed to use it in Access...
Code:
'Version 1.2
'Greg Lovern, July 2009
'http://PrecisionCalc.com

Option Explicit

Private Declare Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
'====================================================================================================
'THIS IS FOR AWS (NOW PRODUCT ADVERTIZING?) SIGNED REQUESTS.
'http://developer.amazonwebservices.com/connect/thread.jspa?threadID=33204&start=15&tstart=0

'To get a signed URL, call GetSignedURL, passing in:
'Your unsigned URL (the URL that would do what you want if signatures were not required).
'Your Access Key ID
'Your Secret Access Key

'To get your "Access Key ID" and "Secret Access Key":
'browse to http://aws.amazon.com
'from the menu, choose Your Account | Access Identifiers.
'when the login page appears, enter the AWS account email and password.
'then see:
'"Your Access Key ID:"
'"Your Secret Access Key:"
'(click Show)

'Example of calling GetSignedURL is test_GetSignedURL:

Sub test_GetSignedURL()
Dim strURL As String
Dim strAccessKeyID As String
Dim strSecretAccessKey As String
Dim strSignedURL As String
'example URL from AWS documentation:
strURL = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Operation=ItemLookup&ItemId=0679722769&ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews&Version=2009-01-06"
'strURL must NOT include these parameters, which will be added by GetSignedURL:
'Timestamp
'AWSAccessKeyId
'Signature
'domain must be "webservices.amazon.com". "ecs.amazonaws.com" will not work with signed requests.
strAccessKeyID = "PUT_YOUR_ACCESS_KEY_ID_HERE" 'Access Key ID
strSecretAccessKey = "PUT_YOUR_SECRET_ACCESS_KEY_HERE" 'Secret Access Key
strSignedURL = GetSignedURL(strURL, strAccessKeyID, strSecretAccessKey)
Debug.Print "Enter this URL in a browser:"
Debug.Print strSignedURL
End Sub
'====================================================================================================

Public Function GetSignedURL(strURL As String, strAccessKeyID As String, strSecretAccessKey As String) 'GJL
'strURL must NOT include these parameters, which will be added to the URL returned by this function:
'Timestamp
'AWSAccessKeyId
'Signature
'The domain in strURL must be "webservices.amazon.com". "ecs.amazonaws.com" will not work with signed requests.

Dim strSignature As String

strURL = strURL & "&Timestamp=" & GetIsoTimestamp
strURL = strURL & "&AWSAccessKeyId=" & strAccessKeyID

GetSignedURL = signEncode(strURL, strSecretAccessKey)

End Function

Private Function GetIsoTimestamp() As String
'Return an ISO 8601 compliant timestamp.
Dim st As SYSTEMTIME
'Get the local date and time.
GetSystemTime st
'Format the result.
GetIsoTimestamp = _
Format$(st.wYear, "0000") & "-" & _
Format$(st.wMonth, "00") & "-" & _
Format$(st.wDay, "00") & "T" & _
Format$(st.wHour, "00") & ":" & _
Format$(st.wMinute, "00") & ":" & _
Format$(st.wSecond, "00") & "Z"
End Function

Function signEncode(ByVal URL As String, SKey As String) As String
Dim http As String
Dim i As Integer, j As Integer
Dim tmp As String
Dim LF As String
Dim header As String
Dim Signature As String
Dim originalURL As String
Dim PVP As Variant 'will become array, but do not declare as array.
'Typical request:
'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=00000000000000000000&Operation=ItemLookup&ItemId=0679722769&ResponseGroup=ItemAttributes,Offers,Images,Reviews&Version=2009-01-06
originalURL = URL
'Encode commas and colon characters
URL = URLClean(URL)
'Split and sort your parameter/value pairs by byte value (not alphabetically, lowercase parameters will be
'listed after uppercase ones).
http = Left$(URL, InStr(URL, "?"))
URL = Mid$(URL, Len(http) + 1)
PVP = Split(URL, "&")
For i = LBound(PVP) To UBound(PVP) - 1
For j = i + 1 To UBound(PVP)
If PVP(i) > PVP(j) Then
tmp = PVP(i)
PVP(i) = PVP(j)
PVP(j) = tmp
End If
Next
Next
'Rejoin the sorted parameter/value list with ampersands. The result is the canonical string that we'll sign
URL = ""
For i = LBound(PVP) To UBound(PVP)
If i UBound(PVP) Then
URL = URL & PVP(i) & "&"
Else
URL = URL & PVP(i)
End If
Next
'Prepend the following three lines (with line breaks) before the canonical string:
'GET
'webservices.amazon.com
'/onca/xml
LF = Chr(10)
Dim strDomain As String
strDomain = GetDomainFromURL(http) 'to handle webservices.amazon.ca, webservices.amazon.co.uk, etc.
header = "GET" & LF & strDomain & LF & "/onca/xml" & LF
'Calculate an RFC 2104-compliant HMAC with the SHA256 hash algorithm using the string above
Signature = HMAC(header & URL, SKey)
Signature = Replace(Signature, "=", "%3D")
Signature = Replace(Signature, "+", "%2B")
signEncode = http & URL & "&Signature=" & Signature
End Function

Function HMAC(ByVal Text As String, ByVal Key As String) As String
Dim oSHA256 As CSHA256
Dim i As Integer
Dim HASH As String
Dim arKey() As Byte
Dim ipad As String, opad As String
'HMAC(key, message) is
'hash ((Key ^ outerpad) + hash((Key ^ innerpad) + message))
'where + denotes concatenation, ^ denotes XOR, and outerpad and innerpad
'are bytes 0x36 and 0x5C, respectively, repeated for the length of the
'key, which is padded with zeros to the block size of the hash.
Set oSHA256 = New CSHA256
'key needs to be 64 bytes long
ReDim arKey(0 To 63)
'first hash the key if it's longer than 64 bytes
If Len(Key) > 64 Then
HASH = oSHA256.SHA256(Key)
Key = StringHex(HASH)
For i = 0 To 63
arKey(i) = Asc(Mid(Key, i + 1, 1))
Next
Else
For i = 0 To Len(Key) - 1
arKey(i) = Asc(Mid(Key, i + 1, 1))
Next
'pad the key array with 0
For i = Len(Key) To 63
arKey(i) = 0
Next
End If
'generate the inner pad and outer pad strings
ipad = ""
opad = ""
For i = 0 To 63
ipad = ipad & Chr(arKey(i) Xor &H36)
opad = opad & Chr(arKey(i) Xor &H5C)
Next
'get the hash of the inner pad and the string
HASH = oSHA256.SHA256(ipad & Text)

'get the hash of the outerpad and the previous hash converted to a string

HASH = oSHA256.SHA256(opad & StringHex(HASH))
'convert the final hash to a string
HASH = StringHex(HASH)
'base64 encode the hash
HMAC = Base64Enc01(HASH)
End Function

Function URLClean(Text As String) As String
'translate only the commas, colons, and spaces
Dim i As Integer
Dim acode As Integer
Dim char As String

URLClean = Text

For i = Len(URLClean) To 1 Step -1
acode = Asc(Mid$(URLClean, i, 1))
Select Case acode
Case 58, 44, 32
'replace punctuation chars with "%hex"
URLClean = Left$(URLClean, i - 1) & "%" & Hex$(acode) & Mid$(URLClean, i + 1)
End Select
If Mid$(URLClean, i, 1) = "?" Then
Exit For
End If
Next

End Function

Function GetDomainFromURL(strURL As String) As String
'looks for "//", and then looks for "/" after the "//", and returns everything between.
'returns empty string on failure.

Dim strTmp As String
Dim iPosDoubleSlash As Long
Dim iPosThirdSlash As Long
iPosDoubleSlash = InStr(strURL, "//")
If iPosDoubleSlash = 0 Then Exit Function 'strURL does not contain "//".
strTmp = Right(strURL, Len(strURL) - (iPosDoubleSlash + 1))
If Len(strURL) = iPosDoubleSlash Then Exit Function 'strURL looks like "http://".
iPosThirdSlash = InStr(strTmp, "/")
If iPosThirdSlash = 0 Then
GetDomainFromURL = strTmp 'strURL looks like "http://MyDomain.com".
Else
GetDomainFromURL = Left(strTmp, iPosThirdSlash - 1)
End If

End Function

Function StringHex(Text As String) As String

Dim lCount 'As Long
Dim sResult 'As String
Dim lLength 'As Long
lLength = Len(Text)
For lCount = 1 To lLength Step 2
sResult = sResult & Chr(Val("&H" & Mid(Text, lCount, 2)))
Next
StringHex = sResult

End Function

Public Function Base64Enc01(S$) As String
'by Nobody, 20011204
Static Enc() As Byte
Dim b() As Byte, Out() As Byte, i&, j&, L&
If (Not Val(Not Enc)) = 0 Then 'Null-Ptr = not initialized
Enc = StrConv("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", vbFromUnicode)
End If
L = Len(S): b = StrConv(S, vbFromUnicode)
ReDim Preserve b(0 To (UBound(b) \ 3) * 3 + 2)
ReDim Preserve Out(0 To (UBound(b) \ 3) * 4 + 3)
For i = 0 To UBound(b) - 1 Step 3
Out(j) = Enc(b(i) \ 4): j = j + 1
Out(j) = Enc((b(i + 1) \ 16) Or (b(i) And 3) * 16): j = j + 1
Out(j) = Enc((b(i + 2) \ 64) Or (b(i + 1) And 15) * 4): j = j + 1
Out(j) = Enc(b(i + 2) And 63): j = j + 1
Next i
For i = 1 To i - L: Out(UBound(Out) - i + 1) = 61: Next i
Base64Enc01 = StrConv(Out, vbUnicode)
End Function

...I took one look at the above code (while considering how little in the way of VBA is out there for this kind of thing) & thought, "Hmm, perhaps I'm better coding in a language where lots of other people are doing the same thing!" At least then there's almost certainly going to be someone who is trodding the same path & can help!

So I take your point, perhaps it could be done in VBA, but I've read many times that VBA is not the best way for doing this....hence thinking, ok let's roll my sleeves up & start on page 1 of learning a language where Amazon have provided libraries.
 
The thing you need to remember is not that you are pulling data from XML but that you are trying to get it into Access. You are asking the wrong question because you are looking at the source, not the destination.

Access natively uses VBA and doesn't give you the most trivial of interfaces such that you could easily call an external module written in some other language to be used inside of Access for some special decode. Oh, it is doable, but the other language has to be capable of creating the required .DLL or other routine library so that your other routines are reachable.

The fact that something is coming in through XML or ASCII or Sanskrit is immaterial. You have the data types (and data-type-definition abilities) that you need in VBA to be able to handle anything assuming you can get it in through a file in some known format. Parsing is parsing regardless of the language.

Stated another way, you could simply learn how to handle the incoming formats in VBA ... OR you could pick another language and learn how to parse the incoming formats in your chosen language AND THEN learn how to interface your programs in your chosen language to get the data to Access - probably through VBA. In essence, seeking to do this in another language is merely adding another layer to what you have to learn.
 
SO I guess I need to get deep down 'n dirty with VBA then! (at this stage of my business's lifecycle, I really can't be done going with SQL.....it's taken me a while to get to grips with Access, so I'm hitching my trailer to it for a while longer)
 
When this question popped up this morning I did a search on Amazon, API and VBA.... There were some interesting results for linking Amazon to excel via VBA. I think that might be a search you could adopt and possibly hijack the Excel VBA code!
 
Oh I just thought, the search may have included XML....
 
I did search a few days ago...I found some excel code, had a dabble with it in Excel & then attempted to use it in Access - I failed. I then realised how seriously lacking my VBA chops were (& for my intended purpose, there's no depth of user base also wanting to achieve the same thing .....safety in number blah blah), hence the creation of this thread.

But maybe I just need to spend a little more time embracing VBA & seeing if I can kludge the Excel VBA code I found as a first step. The irony is I'm sure it's embarrassingly simple to get Excel VBA code working in Access!
 
VBA is VBA regardless of the Office application. The issue isn't that it is Access or Excel.

Where people often get confused is that your application environment governs what collections and other features you can see, but the syntax of the manipulating language is always the same.

For instance, in Access class modules, Me.xxxx is some property or feature of a form.

In Excel, you worry about ActiveWorkbook.xxx properties.

In Word, you worry about ActiveDocument.xxxx properties.

The objects change but the syntax to manipulate them remains the same. (This statement is a form of "divide and conquer" advice at the conceptual level.) If you can step away from the trees, you might see that the forests look a lot more alike than you might first have thought.
 
For instance, in Access class modules, Me.xxxx is some property or feature of a form.

In Excel, you worry about ActiveWorkbook.xxx properties.

In Word, you worry about ActiveDocument.xxxx properties.

It is even more similar than that explanation might suggest.

Code referring to the current class object as Me is just as relevant in Excel or Word as it is in Access. It is used in the ThisWorkbook module to refer to the workbook and in a Worksheet module to refer to the objects on the associated sheet. In Word it is used similarly in ThisDocument module.

One difference in Excel is how to refer to sheets. Using Access Form experience one might be tempted to refer to objects on a worksheet as:
Worksheets("somename")

You can but the problem is, "somename" is the name displayed on the worksheet tab and can be renamed by the user. The code is vulnerable to failure by renaming if this reference is used.

Similarly using the index:
Worksheets(1)
The index changes when the sheets are reordered by the user.

Always refer to a sheet by the name of the object as shown in the Project Explorer. This is the first part of the name, eg Sheet1. The name following it in the brackets is the Name property, the displayed name.

Better still, rename the sheet objects to something meaningful instead of default names. Turn on the Properties Window under the View menu of the VBA editor. Edit the (Name) property of the worksheet.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom