Weka
05-17-2015, 08:10 PM
I have a big challenge on my hands here. I'm not a programmer either, so please go gentle on me. I have a Database that is currently in Access 1.1, yes, you read right. Access 1.1. It is the Accounting "application" of a small business so kind of needed. The ultimate goal here is to drag it kicking and screaming up to Access 2013. I'm not entirely sure if that will be possible. I've been playing around with the vba (?) in a hope to get it working. I've been working my way through it with some success, however, here, I am really stumped. so far i've changed all "user" to "user32" and all Long's were Integer's as I've read that the Integer datatype is not supported in 32 bit. I'm suspicious that these may be API's and not VBA? (or i could be talking a load of rot and given you a great big belly laugh)
Anyhow, If someone with far more skill that me, could please very nicely have a look at this code and tell me A) if it's worth persevering with or B) how to fix this code. If it's not worth fixing, then I will need to develop a whole new database which will have it's own challenges for me.
I'm currently trying to open it into Access 97. (then i'll convert it with 2003) Currently I am getting a "ByRef argument type mismatch" error which i kind of understand.
Anyhow..... here's the current code i'm stuck on.
Declare Function wu_GetClientRect Lib "User32" Alias "GetClientRect" (ByVal hwin%, rectangle As WU_RECT) As Long
'------------------------------------------------------------------------
' FUNCTION : wu_CenterDoc
'
' PURPOSE : Centers a Microsoft Access form.
'------------------------------------------------------------------------
Function wu_CenterDoc(hwnd%) As Long
Dim r As WU_RECT, rDesk As WU_RECT
Dim dx As Long, dy As Long, dxDesk As Long, dyDesk As Long
If (hwnd% = 0) Then hwnd = wu_GetCurrentDoc(True)
hwndDesk% = wu_GetParent(hwnd%)
stClass$ = wu_StWindowClass(hwnd%)
' Special case for forms: Move them to 0,0 and do a SizeToFitForm
If (stClass$ = WU_WC_ACCESSFRM) Then
DoCmd.MoveSize 0, 0
On Error Resume Next
DoCmd.DoMenuItem A_FORMBAR, 4, 5
On Error GoTo 0
End If
' If this is a popup, use the WindowRect of the desktop. Otherwise,
' use the client rect.
f% = wu_GetWindowRect(hwnd%, r)
If (stClass$ = WU_WC_ACCESSFRMPOPUP) Then
f% = wu_GetWindowRect(hwndDesk%, rDesk)
Else
f% = wu_GetClientRect(hwndDesk%, rDesk)
End If
dx% = r.x2 - r.x1
dy% = r.y2 - r.y1
dxDesk% = rDesk.x2 - rDesk.x1
dyDesk% = rDesk.y2 - rDesk.y1
If (wu_StWindowClass(hwnd%) = WU_WC_ACCESSFRMPOPUP) Then
f% = wu_MoveWindow(hwnd%, rDesk.x1 + (dxDesk% - dx%) / 2, rDesk.y1 + (dyDesk% - dy%) / 2, dx%, dy%, True)
Else
f% = wu_MoveWindow(hwnd%, (dxDesk% - dx%) / 2, (dyDesk% - dy%) / 2, dx%, dy%, True)
End If
wu_CenterDoc = f%
End Function
Thank you in advance
Weka
:banghead:
Anyhow, If someone with far more skill that me, could please very nicely have a look at this code and tell me A) if it's worth persevering with or B) how to fix this code. If it's not worth fixing, then I will need to develop a whole new database which will have it's own challenges for me.
I'm currently trying to open it into Access 97. (then i'll convert it with 2003) Currently I am getting a "ByRef argument type mismatch" error which i kind of understand.
Anyhow..... here's the current code i'm stuck on.
Declare Function wu_GetClientRect Lib "User32" Alias "GetClientRect" (ByVal hwin%, rectangle As WU_RECT) As Long
'------------------------------------------------------------------------
' FUNCTION : wu_CenterDoc
'
' PURPOSE : Centers a Microsoft Access form.
'------------------------------------------------------------------------
Function wu_CenterDoc(hwnd%) As Long
Dim r As WU_RECT, rDesk As WU_RECT
Dim dx As Long, dy As Long, dxDesk As Long, dyDesk As Long
If (hwnd% = 0) Then hwnd = wu_GetCurrentDoc(True)
hwndDesk% = wu_GetParent(hwnd%)
stClass$ = wu_StWindowClass(hwnd%)
' Special case for forms: Move them to 0,0 and do a SizeToFitForm
If (stClass$ = WU_WC_ACCESSFRM) Then
DoCmd.MoveSize 0, 0
On Error Resume Next
DoCmd.DoMenuItem A_FORMBAR, 4, 5
On Error GoTo 0
End If
' If this is a popup, use the WindowRect of the desktop. Otherwise,
' use the client rect.
f% = wu_GetWindowRect(hwnd%, r)
If (stClass$ = WU_WC_ACCESSFRMPOPUP) Then
f% = wu_GetWindowRect(hwndDesk%, rDesk)
Else
f% = wu_GetClientRect(hwndDesk%, rDesk)
End If
dx% = r.x2 - r.x1
dy% = r.y2 - r.y1
dxDesk% = rDesk.x2 - rDesk.x1
dyDesk% = rDesk.y2 - rDesk.y1
If (wu_StWindowClass(hwnd%) = WU_WC_ACCESSFRMPOPUP) Then
f% = wu_MoveWindow(hwnd%, rDesk.x1 + (dxDesk% - dx%) / 2, rDesk.y1 + (dyDesk% - dy%) / 2, dx%, dy%, True)
Else
f% = wu_MoveWindow(hwnd%, (dxDesk% - dx%) / 2, (dyDesk% - dy%) / 2, dx%, dy%, True)
End If
wu_CenterDoc = f%
End Function
Thank you in advance
Weka
:banghead: