neuroman9999
Member
- Local time
- Today, 08:11
- Joined
- Aug 17, 2020
- Messages
- 824
guys,
has anyone designed an app in access that literally did the same thing over and over again? if so, how did you use functions that were to be called a million times with different args each time? here's an example:
and then of course, behind any given form's "save record" button, would be something like this:
I realize there is redundancy in that code, but the idea is there. is that the way all you guys do it? if of course, you get to do what you want to do as pros, and not just throw crap together because management has no idea what they're doing and/or their customers are nuts and change their mind 24/7? 
has anyone designed an app in access that literally did the same thing over and over again? if so, how did you use functions that were to be called a million times with different args each time? here's an example:
PHP:
public function dataEntered(ctrls() as string, frm as string) as boolean
dim i as long
for i = lbound(ctrls) to ubound(ctrls)
if isnull(forms(frm).controls(ctrls(i))) then 'required field not filled in. throw error
dataEntered = false
exit function
end if
next i
dataEntered = true
end function
PHP:
private sub btnSave_click()
dim arr() as string
dim c as control
dim i as long
i = 0
for each c in me.controls
if typeof c is textbox then
if i = 0 then
redim arr(i)
arr(i) = c.name
else
redim preserve arr(i)
arr(i) = c.name
end if
i = i+1
end if
next c
if dataEntered(arr(), me.name) then
docmd.runcommand(accmdsaverecord)
msgbox "Record has been saved!",vbinformation,"Confirm"
docmd.gotorecord acnew
else
msgbox "All fields are required to be filled in!", vbcritical, "Error"
end if
