carriage return/ line feed

ariel81

Registered User.
Local time
Today, 13:40
Joined
Dec 31, 2006
Messages
75
Dim f As Form
Dim g As Form

Set f = Forms!frmInputBox
Set g = Forms!frmCalendar

g("Text" & f!InputDay) = f!InputText & vbCrLf& & f!InputText2


e.g: InputText is 123, InputText2 is abc
I wanted to display the text inside textbox of frmCalendar as:
123
abc
instead of 123abc. how shall i use the vbCrLf?
 
Experiment with Chr(13) and Chr(10) or combinations of both.

EG

"First line" & Chr(13) & Chr(10) & "Second Line"

g("Text" & f!InputDay) = f!InputText & Chr(13) & Chr(10) & f!InputText2

Dave
 
thanks...

now that the textbox (frmCalender) can display this way:
123
abc

if i were to transfer the abv to textboxs of (frmInputBox)
123 -> InputText
abc-> InputText2

how shall i write?

With Forms!frmInputBox
!InputDay = mynum
!InputDate = f("Date" & mynum)
!InputFor = g
!original_text = f("Text" & mynum)
!InputText = f("Text" & mynum)
!InputText.SetFocus
!InputText2 = f("Text" & mynum) 'this doesn't work
!InputText2.SetFocus 'this doesn't work
End With
 
ariel81 said:
With Forms!frmInputBox
!InputText2 = f("Text" & mynum) 'this doesn't work
!InputText2.SetFocus 'this doesn't work
End With

Check that the textbox is actually called InputText2

Dave
 
yes its named InputText2

the calender textbox "Text1, Text2,..." properties (on click) in frmCalender has source code for it. but it doesn't seems to work with this added in (see attachment):

With Forms!frmInputBox
!InputText2 = f("Text" & mynum) 'this doesn't work
!InputText2.SetFocus 'this doesn't work
End With

thank you
 

Attachments

Commented out the "SetFocus" lines and it worked fine for me ???

Dave
 
thanks for your help. it doesn't work...

e.g for a date whose datas are:

20
17

20 should be in InputText
17 should be in InputText2
 
If you look at your code, you are trying to copy the same thing to each text box - f("Text" & mynum)

Are you saying you want to be able to enter separate data in each text box, copy the data to the calendar with a line feed, but when the calendar is clicked, split the data back into 2 fields again?

If so, I would add an extra field to your table so the data is always seperated
and then combined when required.

Dave

*Edit*
Just took anothr look at your Db and you are aleady doing that. Sorry
 
Last edited:
Try this in the modCalendar module

Function SendToInputBox(mynum)
Dim Db As DAO.Database
Dim rst As DAO.Recordset
Dim f As Form
Dim g As String
Dim r As Date

Set Db = CurrentDb()

Set f = Forms!frmCalendar
g = Format(f("Date" & mynum), "dddd mmmm d, yyyy")

Set rst = Db.OpenRecordset("tblInput", dbOpenDynaset)

DoCmd.OpenForm "frmInputBox"

With Forms!frmInputBox
!InputDay = mynum
!InputDate = f("Date" & mynum)
!InputFor = g
!original_text = f("Text" & mynum)

r = Format(f("Date" & mynum), "mm/dd/yy")
rst.FindFirst "InputDate = #" & r & "#"

If Not rst.NoMatch Then
!InputText = rst!InputText
!InputText2 = rst!InputText2
End If

End With

SendKeys "{F2}^{HOME}", False

End Function
 
thank you.

now i have added a textbox called "InputTextResult" in frmCalender.
- the function of the "InputTextResult" is to display the (results of adding all the values in InputText of the month).

e.g:

45 3 22 = 70 ( result of InputText)
21 1 16 = 38 (result of InputText2)

shall temporary ignore the InputText2 because its something similar to InputText.

here is what i edit in Public Sub PutInData() :
Code:
Public Sub PutInData()
    Dim sql As String
    Dim f As Form
    Dim Db As DAO.Database
    Dim rs As DAO.Recordset
    Dim i As Integer
    Dim InputTextAdder As Integer  'ariel81
    Dim ans As Integer  'ariel81
    Dim myDate As Date
    
    Set f = Forms!frmCalendar
    ans = 0   'ariel81
    InputTextAdder = 0   'ariel81
    
     
'Empty out the previous month
    For i = 1 To 37
        f("text" & i) = Null
        f("text" & i).BackColor = 10944511
    Next i
    
'Construct a record source for the month
    sql = "SELECT * FROM [tblInput] WHERE ((MONTH(InputDate) = " & f!month & "  AND YEAR(InputDate)= " & f!year & ")) ORDER BY InputDate;"
        
    Set Db = CurrentDb()
    Set rs = Db.OpenRecordset(sql, dbOpenSnapshot)
    
'Populate the calendar
    If rs.RecordCount > 0 Then
        For i = 1 To 37
            If IsDate(f("date" & i)) Then
                myDate = Format((f("date" & i)), "mm/dd/yyyy")
                rs.FindFirst "InputDate = #" & myDate & "#"
                If Not rs.NoMatch Then
                    f("text" & i) = rs!InputText & Chr(13) & Chr(10) & rs!InputText2
                    InputTextAdder = rs!InputText   'ariel81
                    ans = InputTextAdder + InputTextAdder 'ariel81
                    f("InputTextResult") = ans  'ariel81
                    f("text" & i).BackColor = 12058551
                Else
                    f("text" & i).BackColor = 10944511
                End If
            End If
        Next i
    End If

End Sub

codes added inside:

Dim InputTextAdder As Integer
Dim ans As Integer

ans = 0
InputTextAdder = 0

If Not rs.NoMatch Then
f("text" & i) = rs!InputText & Chr(13) & Chr(10) & rs!InputText2
InputTextAdder = rs!InputText 'ariel81
ans = InputTextAdder + InputTextAdder 'ariel81
f("InputTextResult") = ans 'ariel81
f("text" & i).BackColor = 12058551
Else

* the ans of adding InputText doesn't seems correct.
 

Users who are viewing this thread

Back
Top Bottom