|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: |
VBA module (PB Listing is the name of my table):-
'UpdateCharges("x","x")
Public Function UpdateCharges(xlPath As String, wsName As String)
wsName = "cons_summary_20081231_starhub l"
xlPath = "C:\Documents and Settings\Desktop\New Folder\sample.xls"
Stop
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Dim xlWs As Excel.Worksheet
'Dim rsData As New ADODB.Recordset
Dim i As Long
Dim fCollection As New Collection
Dim fld As dao.Field
Dim rsData As dao.Recordset
Dim tblName As String
Dim CID As Variant
tblName = "PB Listing" ' Replace this with the name of your table
On Error Resume Next
' Try get a handle to a pre-existing copy of Excel
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ' Excel not open
Set xlApp = New Excel.Application
xlApp.Visible = True
End If
Set xlWb = xlApp.Workbooks.Open(xlPath, , True) ' open the workbook
Set xlWs = xlWb.Worksheets(wsName) ' get the correct worksheet
Set rsData = CurrentDb.OpenRecordset("PBSorted") ' open our table
For i = 1 To xlWs.UsedRange.Rows.Count
rsData.MoveFirst
CID = DLookup("[Contract ID]", tblName, "[CA No] = " & """" & xlWs.Cells(i, 1).Value & """")
rsData.FindFirst "[CA No] = " & """" & xlWs.Cells(i, 1).Value & """"
Debug.Print rsData.Fields("CA No"), xlWs.Cells(i, 1).Value
Debug.Print rsData.Fields("Contract ID")
If "" = (xlWs.Cells(i, 1).Value) Then
MsgBox ("Done")
GoTo funclosethisout
End If
For Each fld In rsData.Fields ' keep track of current field values
fCollection.Add fld.Value, fld.Name
Next
'If no match then need the new CA No.
If rsData.NoMatch Then fCollection("CA No") = xlWs.Cells(i, 1).Value
' Stop
rsData.AddNew ' create our new record
For Each fld In rsData.Fields
fld.Value = fCollection(fld.Name) ' fld.Value = fCollection(fld.Name)
Next
'Stop
' reset our collection
Set fCollection = Nothing
Set fCollection = New Collection
rsData.Fields("Total Charges").Value = xlWs.Cells(i, 2).Value ' put in the new value
rsData.Update
Next
funclosethisout:
xlWb.Close
xlApp.ActiveWorkbook.Close
xlApp.ActiveWindow.Close
Set xlApp = Nothing
End Function
|
Advertisement
| Hall of Fame |