Creating a string

Gamezy

Registered User.
Local time
Today, 18:04
Joined
Jun 29, 2006
Messages
25
Function MakeString() As String

Dim stringy As String
stringy = "1"

If [Forms]![TimeSick]![M].Value = 0 Then
stringy = stringy & "2"
End If

If [Forms]![TimeSick]![Tu].Value = 0 Then
stringy = stringy & "3"
End If

If [Forms]![TimeSick]![W].Value = 0 Then
stringy = stringy & "4"
End If

If [Forms]![TimeSick]![Th].Value = 0 Then
stringy = stringy & "5"
End If

If [Forms]![TimeSick]![F].Value = 0 Then
stringy = stringy & "6"
End If

stringy = stringy & "7"
End Function

Don't understand why this isn't working. I want to create a string from data in a form, and then pass this into another function. Any ideas? Think it's something simple I'm missing.
 
Well, you haven't returned the string ;)

at the end of the function, put a line that says
Code:
MakeString = stringy
that returns stringy as the result of MakeString()
 
Lol, /doh!

Figured that out after about 30 minutes of being a blind fool, thanks!
Now all I have to do is get my Available days function to check for bank holidays and the such. So far I've got:

Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer

On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database

Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)

intCount = 0
Do While StartDate <= EndDate

rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If rst.NoMatch Then intCount = intCount + 1

StartDate = StartDate + 1
Loop

WorkingDays2 = intCount

But I keep getting an error when the code on my form saying not enough parameter, 1 expected. Any thoughts on that?
 
Lol, /doh!

Figured that out after about 30 minutes of being a blind fool, thanks!
Now all I have to do is get my Available days function to check for bank holidays and the such. So far I've got:

Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer

On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database

Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)

intCount = 0
Do While StartDate <= EndDate

rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If rst.NoMatch Then intCount = intCount + 1

StartDate = StartDate + 1
Loop

WorkingDays2 = intCount

But I keep getting an error when the code on my form saying not enough parameter, 1 expected. Any thoughts on that?
 
Lol, /doh!

Figured that out after about 30 minutes of being a blind fool, thanks!
Now all I have to do is get my Available days function to check for bank holidays and the such. So far I've got:

Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer

On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database

Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)

intCount = 0
Do While StartDate <= EndDate

rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If rst.NoMatch Then intCount = intCount + 1

StartDate = StartDate + 1
Loop

WorkingDays2 = intCount

But I keep getting an error when the code on my form saying not enough parameter, 1 expected. Any thoughts on that?
 
Lol, /doh!

Figured that out after about 30 minutes of being a blind fool, thanks!
Now all I have to do is get my Available days function to check for bank holidays and the such. So far I've got:

Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer

On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database

Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)

intCount = 0
Do While StartDate <= EndDate

rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If rst.NoMatch Then intCount = intCount + 1

StartDate = StartDate + 1
Loop

WorkingDays2 = intCount

But I keep getting an error when the code on my form saying not enough parameter, 1 expected. Any thoughts on that?
 
Check the actual table and field names to ensure they correspond to your code. [HolidayDate] is the prime suspect.

Bob
 

Users who are viewing this thread

Back
Top Bottom