PDA

View Full Version : Access 1.1 to Access 2013



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:

jonh
05-18-2015, 03:02 AM
Remove the code and try the form's 'Auto Center' property instead.

Weka
05-18-2015, 03:47 AM
Remove the code and try the form's 'Auto Center' property instead.

Seriously that's all it's doing? shesh, well that proves how out of my depth i am, surely I should have picked that up, what's the saying a little knowledge is dangerous? lol. Ok, so I have commented that whole function out, and looked at the form properties, and on the next compile it successfully gets past here (obviously), and few more functions, then complains here
stClass$ = wu_StWindowClass(hwnd%)
error being
type declaration character does not match declared datatype. OK, so I understand what this is saying, only I don't know how to look up what the datatype is, which i presume would be the first step to fixing this. I'm guessing that in true cowboy style i did a find and replace for integer to Long, and that since integer being 16 bit was replaced by either long or byte then something should be the other. Is this on the right track?

jonh
05-18-2015, 04:25 AM
Heh, yep that's all it was doing. :)

hwind (window handle) is the operating system's way of tracking window objects. So you can bet that any piece of code referring to hwnd is using the Windows API to move or resize or otherwise manipulate a form or report.

99.9% of the time it's a sign of something being over designed and can be ripped out without too much worry.

Weka
05-20-2015, 02:20 AM
Thank you so much for you help. I really mean it. I've managed to run with your info and by tinkering and altering screen properties to do what the code was saying (now that I know what hwind is!) :). I've now got it up into access 2003 opened and mostly running. I've got two tiny errors left that are only small show stoppers, but i'll keep tinkering away for a bit to see if I can work them out. I'm sure they will be easy to fix once I know how. Time to shake the google tree and see what nuggets of info fall out (and dig through here too of course as I'm sure someone else must have asked the question before)