Hey Everyone
I recently got employed in a local call centre. One of my first tasks is to fix the problems with the postcode validation. They have been running a QAS Pro 6.74 server for near 2 years now. It appears to work, however certain postcodes bring back the wrong address.
The person I replaced wrote a reference DLL to link access to the QAS server (hosted internally). Its based on the sample code QAS provide and is written in C#. We only use the one-line function to get a full address from the postcode. For this access needs to use 2 different functions. The first returns a combo box of possible address and when selected the second function will format the address, send it back to access and have it appended in the correct fields.
An example of the address problems.
If I enter the postcode: PA16 9AE.
It will give a list of address, such as: 0/3 15 Brachelston Street, GREENOCK, Renfrewshire
When I select any address with a forward slash in it, I always get back:
1 Crossgates, Greenock Road, BISHOPTON, Renfrewshire
I have been working on this for over 2 weeks now with no success. I've exhausted every forum and Google search I can. I'm new to C# so my knowledge is limited. If anyone has got this working and could assist I would greatly appreciate it.
If I missed any code, let me know. Theres quite a bit pulled into the reference, so I didn't want to post all.
The C# code to interact with the server:
The Access code to communicate with the reference:
I recently got employed in a local call centre. One of my first tasks is to fix the problems with the postcode validation. They have been running a QAS Pro 6.74 server for near 2 years now. It appears to work, however certain postcodes bring back the wrong address.
The person I replaced wrote a reference DLL to link access to the QAS server (hosted internally). Its based on the sample code QAS provide and is written in C#. We only use the one-line function to get a full address from the postcode. For this access needs to use 2 different functions. The first returns a combo box of possible address and when selected the second function will format the address, send it back to access and have it appended in the correct fields.
An example of the address problems.
If I enter the postcode: PA16 9AE.
It will give a list of address, such as: 0/3 15 Brachelston Street, GREENOCK, Renfrewshire
When I select any address with a forward slash in it, I always get back:
1 Crossgates, Greenock Road, BISHOPTON, Renfrewshire
I have been working on this for over 2 weeks now with no success. I've exhausted every forum and Google search I can. I'm new to C# so my knowledge is limited. If anyone has got this working and could assist I would greatly appreciate it.
If I missed any code, let me know. Theres quite a bit pulled into the reference, so I didn't want to post all.
The C# code to interact with the server:
Code:
public QAS()
{
QuickAddress address = new QuickAddress("[Link to server]") {
Engine = QuickAddress.EngineTypes.Singleline,
Flatten = true
};
this.searchService = address;
}
private string GetMoniker(string p)
{
return this.searchService.Search("GBR", p, PromptSet.Types.OneLine, "Database layout").Picklist.Items[0].Moniker;
}
public string[] RefinePostcode(string p)
{
string moniker = this.GetMoniker(p);
FormattedAddress formattedAddress = this.searchService.GetFormattedAddress(moniker, "Database Layout");
return new string[] { formattedAddress.AddressLines[0].Line, formattedAddress.AddressLines[1].Line, formattedAddress.AddressLines[2].Line, formattedAddress.AddressLines[3].Line, formattedAddress.AddressLines[4].Line, formattedAddress.AddressLines[5].Line, formattedAddress.AddressLines[6].Line };
}
public string[] SearchPostcodes(string postCode)
{
SearchResult result = this.searchService.Search("GBR", postCode, PromptSet.Types.OneLine, "Database layout");
string[] strArray = new string[result.Picklist.Length];
for (int i = 0; i < result.Picklist.Length; i++)
{
strArray[i] = result.Picklist.Items[i].Text;
}
return strArray;
}
The Access code to communicate with the reference:
Code:
Private Sub cmdSelect_Click()
Dim thisOne As String
thisOne = Me.lkupAddressList.Value
Dim objQAS As MangoQAS.QAS
Set objQAS = New MangoQAS.QAS
Dim finalAddress As Variant
finalAddress = objQAS.RefinePostcode(thisOne)
Form_Script.txtAddress1 = finalAddress(0)
Form_Script.txtAddress2 = finalAddress(1)
Form_Script.txtAddress3 = finalAddress(2)
Form_Script.txtTown = finalAddress(3)
Form_Script.txtCounty = finalAddress(4)
Form_Script.txtPostcode = finalAddress(5)
Set objQAS = Nothing
DoCmd.Close acForm, "frmSelectAddress_qas"
End Sub
Private Sub Form_Load()
Dim postcodeToSearch As String
postcodeToSearch = Form_Script.txtPostcode
Dim objQAS As MangoQAS.QAS
Set objQAS = New MangoQAS.QAS
Dim results As Variant
results = objQAS.SearchPostcodes(postcodeToSearch)
Dim howMany As Integer
howMany = UBound(results)
For i = 0 To howMany
Me.lkupAddressList.AddItem ("'" & results(i) & "'")
Next
Set objQAS = Nothing
End Sub