silentwolf
Active member
- Local time
- Yesterday, 16:12
- Joined
- Jun 12, 2009
- Messages
- 644
Hi guys,
hope I am not getting anyone on the nerves for asking again!?
This is like a little recap of different discussion and threads I had in previous posts.
Not sure if that is the way to point to a previous discussion?
Implements and Class specific methodes
As I like to reuse some of my code I deside to use a class Module to do so.
However there remains some questions for me and I was hoping for some Ideas.
I have read all your suggestions and I can't agree more on not trying to complicated more then anything else!
That is way I am still trying to find a solution or better a best practice type of approche for what I try do accomplish.
Below there is a part of my code which has also been discussed here and many of great help I did receive!
So that is not really the issue.
As mentioned that is a part a small part of a project.
What I did is I created a Class Module where I put something like
Properties:
*TableName
*FileName
Methode:
*ClearTable(tableName as string)
*ImportData(fileName as string)
In this kind of enviroment there is all clear for me to set it Up in a Class and it makes live a little easier and reusable.
However.
If I like to include the above Code in the Class there comes the Issue.
I got a Form with just two buttons btnBrowse, btnImport and a textBox txtFileName
I guess it is obvious what I like to do.. brows for the File, hit the Import Button and hopefully all goes to plan and the File gets Imported and Updated so
I can further process or save it and so on.
Question:
-When I try to put the custom functions and I do have a few in that particular Project to update "Strings" where should I put those? In the Same Class? In a Module? In the FormClass?
When I try to put the CustomFunctions in the Class module and Try to Run the "Public Sub UpdateAuszug(TableName As String)" it gives me an Error.
If I keep the Custom Function in a codeModule modFunctions It all works well.
So I do not like to complicate things but I like to have it kind of all in one place for reusability.
I learn from Tutorials and also Books and of course from you guys but Examples are always easier as the real live projects. And there I do have still a lack of understanding to have a good reusable and compact "project" so to speak.
Maybe some can let me know how you track this kind of "projects" either with a Class or without or in the FormClass Module.
Hope it makes sense to you what I am saying and get some input how you track those kind of projects.
Would be much appreciated!
P.S. I read of course all your suggestions in the previous discussions and I do understand them but still have some issues of not getting to sidetracked and get my project all messed up.
Cheers
hope I am not getting anyone on the nerves for asking again!?
This is like a little recap of different discussion and threads I had in previous posts.
Not sure if that is the way to point to a previous discussion?
Implements and Class specific methodes
As I like to reuse some of my code I deside to use a class Module to do so.
However there remains some questions for me and I was hoping for some Ideas.
I have read all your suggestions and I can't agree more on not trying to complicated more then anything else!
That is way I am still trying to find a solution or better a best practice type of approche for what I try do accomplish.
Below there is a part of my code which has also been discussed here and many of great help I did receive!
So that is not really the issue.
Code:
Public Sub UpdateAuszug(TableName As String)
Dim db As DAO.Database
Dim tbd As DAO.TableDef
Dim strSQL As String
Set db = CurrentDb
Set tbd = db.TableDefs(TableName)
strSQL = "UPDATE " & TableName & " SET Umsatztext = KillBlanks([Umsatztext])"
db.Execute strSQL
Set tbd = Nothing
Set db = Nothing
End Sub
'Custom Function to delete blanks within a string
Public Function KillBlanks(TempString)
Dim Temp As String
Dim Zeichen As String
Dim NeuerString As String
Dim Gefunden As Boolean
Dim i As Integer
Gefunden = False
NeuerString = ""
If IsNull(TempString) Then
' Wenn kein Inhalt im Feld vorhanden ist,
' wird die Funktion abgebrochen
Exit Function
Else
Temp = CStr(TempString)
For i = 1 To Len(Temp)
Zeichen = Mid$(Temp, i, 1)
If Zeichen = Chr(32) Then
If Not Gefunden Then
Gefunden = True
NeuerString = NeuerString & Zeichen
End If
Else
NeuerString = NeuerString & Zeichen
Gefunden = False
End If
Next i
' Das Ergebnis wird an die Funktion wieder übergeben
KillBlanks = NeuerString
End If
End Function
As mentioned that is a part a small part of a project.
What I did is I created a Class Module where I put something like
Properties:
*TableName
*FileName
Methode:
*ClearTable(tableName as string)
*ImportData(fileName as string)
In this kind of enviroment there is all clear for me to set it Up in a Class and it makes live a little easier and reusable.
However.
If I like to include the above Code in the Class there comes the Issue.
I got a Form with just two buttons btnBrowse, btnImport and a textBox txtFileName
I guess it is obvious what I like to do.. brows for the File, hit the Import Button and hopefully all goes to plan and the File gets Imported and Updated so
I can further process or save it and so on.
Question:
-When I try to put the custom functions and I do have a few in that particular Project to update "Strings" where should I put those? In the Same Class? In a Module? In the FormClass?
When I try to put the CustomFunctions in the Class module and Try to Run the "Public Sub UpdateAuszug(TableName As String)" it gives me an Error.
If I keep the Custom Function in a codeModule modFunctions It all works well.
So I do not like to complicate things but I like to have it kind of all in one place for reusability.
I learn from Tutorials and also Books and of course from you guys but Examples are always easier as the real live projects. And there I do have still a lack of understanding to have a good reusable and compact "project" so to speak.
Maybe some can let me know how you track this kind of "projects" either with a Class or without or in the FormClass Module.
Hope it makes sense to you what I am saying and get some input how you track those kind of projects.
Would be much appreciated!
P.S. I read of course all your suggestions in the previous discussions and I do understand them but still have some issues of not getting to sidetracked and get my project all messed up.
Cheers