johnsonhuo
Registered User.
- Local time
- Tomorrow, 06:15
- Joined
- Mar 12, 2018
- Messages
- 11
I really need help with my VBA code
problem 1
Dim sBody As String
Dim rst1 As DAO.Recordset
Set rst1 = db.OpenRecordset("Select * From OilSampleEmail")
While Not rst1.EOF
sBody = "<html><body><p>" & sBody & Nz(rst1!Set, "") & " " & Nz(rst1!Car, "") & "</p></body></html>"
rst1.MoveNext
Wend
With this one, the output always has one blank line after the first line, and the rest are normal. The output result is like
AAA
BBB
CCC
DDD
but the expected result should be
AAA
BBB
CCC
DDD
I have no idea how this could happen with my code.
Problem 2
Private Sub Command16_Click()
If Me.Text6.Value = "Null" Then
MsgBox "Please input Set Number"
ElseIf Me.Text10 = "" Then
MsgBox "Please input Car Number"
Else
CurrentDb.Execute "insert into OilSampleEmail ([Set], [Car]) values ('" & Me.Text6 & "', '" & Me.Text10 & "')"
Command18_Click
End If
For this one, it is similar to problem 1. Every first time I open this form, the 'if function' does not work at all. All conditions stated by 'if function' don't apply. However, the rest input will be fine with the conditions.
Thank you very much for your help!
problem 1
Dim sBody As String
Dim rst1 As DAO.Recordset
Set rst1 = db.OpenRecordset("Select * From OilSampleEmail")
While Not rst1.EOF
sBody = "<html><body><p>" & sBody & Nz(rst1!Set, "") & " " & Nz(rst1!Car, "") & "</p></body></html>"
rst1.MoveNext
Wend
With this one, the output always has one blank line after the first line, and the rest are normal. The output result is like
AAA
BBB
CCC
DDD
but the expected result should be
AAA
BBB
CCC
DDD
I have no idea how this could happen with my code.
Problem 2
Private Sub Command16_Click()
If Me.Text6.Value = "Null" Then
MsgBox "Please input Set Number"
ElseIf Me.Text10 = "" Then
MsgBox "Please input Car Number"
Else
CurrentDb.Execute "insert into OilSampleEmail ([Set], [Car]) values ('" & Me.Text6 & "', '" & Me.Text10 & "')"
Command18_Click
End If
For this one, it is similar to problem 1. Every first time I open this form, the 'if function' does not work at all. All conditions stated by 'if function' don't apply. However, the rest input will be fine with the conditions.
Thank you very much for your help!