Fordraiders
asked on
Update routine for standard module function
Curently this code works for a form module:
I need to work in module to make a function call.
https://www.experts-exchange.com/questions/21499562/Use-jpg-files-and-create-new-jpg-files-for-non-duplicate-names-Using-Table-data.html
reference question: above.
Dim rs
Dim pathname, newpathname, itemname, picname As String
pathname = "C:\Images\"
newpathname = "C:\Images\New\"
Me.RecordSource = "SELECT * FROM NoPic_Picture_NotAll" <<<<---error here...invalid use of "me"...
Set rs = Me.Recordset.Clone
rs.MoveFirst
While Not rs.EOF
itemname = rs!material_no
picname = rs!primary_image2
If itemname <> picname Then
FileCopy pathname & picname, newpathname & itemname & ".JPG"
End If
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
This code is used within a form module...
I need to update this to run whithin a standard module please...
Thanks
fordraiders
I need to work in module to make a function call.
https://www.experts-exchange.com/questions/21499562/Use-jpg-files-and-create-new-jpg-files-for-non-duplicate-names-Using-Table-data.html
reference question: above.
Dim rs
Dim pathname, newpathname, itemname, picname As String
pathname = "C:\Images\"
newpathname = "C:\Images\New\"
Me.RecordSource = "SELECT * FROM NoPic_Picture_NotAll" <<<<---error here...invalid use of "me"...
Set rs = Me.Recordset.Clone
rs.MoveFirst
While Not rs.EOF
itemname = rs!material_no
picname = rs!primary_image2
If itemname <> picname Then
FileCopy pathname & picname, newpathname & itemname & ".JPG"
End If
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
This code is used within a form module...
I need to update this to run whithin a standard module please...
Thanks
fordraiders
Aside from Jerry's question of 'Why do you need this in a separate code module', which can go a number of directions..
In a separate code module
In a separate code module
Public Function fn_whatever (frm as Form) as Whatever
'do your stuff here. Below is a form reference.
frm.RecordSource = "SELECT * FROM NoPic_Picture_NotAll"
End Function
Then in your form, call the function, passing in the form objectCall fn_whatever(Me)
>Dim pathname, newpathname, itemname, picname As String
btw, don't do this, as if you don't specify a variable type for EVERY variable, Access will define them as Variants, which could cause unintended errors or other bad stuff to happen.
Dim pathname as String, newpathname as String, itemname as String, picname As String
btw, don't do this, as if you don't specify a variable type for EVERY variable, Access will define them as Variants, which could cause unintended errors or other bad stuff to happen.
Dim pathname as String, newpathname as String, itemname as String, picname As String
ASKER
jerry, nothing to do with a form anymore...just a standard module
ASKER
i need to just call the procedure from a standard module..
I'm not using a form anymore..
Thanks
I'm not using a form anymore..
Thanks
>i need to just call the procedure from a standard module
Okay, but your function has Me.RecordSource, so explain for us how you plan on referencing forms when called from a separate code module.
Are we talking only one form, or multiple, or some logic that says one or another?
Okay, but your function has Me.RecordSource, so explain for us how you plan on referencing forms when called from a separate code module.
Are we talking only one form, or multiple, or some logic that says one or another?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, Jerry answered my question...
Sorry for the oversight.
Sorry for the oversight.
ty
Dim rs as dao.recordset
Dim pathname, newpathname, itemname, picname As String
pathname = "C:\Images\"
newpathname = "C:\Images\New\"
Set rs = currentdb.openrecordset("S
rs.MoveFirst
While Not rs.EOF