Need VBA Code

F

FA

I need a VBA function that takes two values
Val1 As String
Val2 As Date

Combine them and return a single value As String and insert them into a
texbox.

Can someone help me please?

Thanks Bunch

Moe
 
F

fredg

I need a VBA function that takes two values
Val1 As String
Val2 As Date

Combine them and return a single value As String and insert them into a
texbox.

Can someone help me please?

Thanks Bunch

Moe

How did you wish the date formatted?

Val1 = "Your payment is due on"
Val2 = #1/9/2006#

Start with an Unbound text control.
Set it's control source to:
=Val1 & " " & Format(Val2,"mmmm d, yyyy") & "."

Your payment is due on January 9, 2006.
 
F

FA

Dim Val1 As String
Dim Val2 As Date
Dim Val3 As String

Combine Val1Val2 and return a single value Val3 As String

With Val3 Add 001 for the first record 002 for the second record and so

on
insert Val3001 into a texbox
So for Example if Val1 = ABCDE, Val2 = 01/01/2006
Val3 shoule be = ABCDE01/01/2006001 --- for the first recode (or for
the first time)


I have created the following funtion

Public Function CalculateFindingNo(Val1 As String, Val2 As Date, RecNo
As Long) As String
CalculateFindingNo = Val1 & Val2 & RecNo
End Function
I have three textboxes --- txtbox1 (Val1) , txtbox2 (Val2),
txtbox3(Val3)
In the afterupdate event of txtbox2 i have
Me.txtbox3 = CalculateFindingNo (me.txtbox1, me.txtbox2, RecNo)

Its not working Pal

Pleae someone help me

Moe
 
A

Allan Murphy

What is your result in txtbox3

What values are you passing in, is txtbox2 in a date format

I have changed your code slightly so that the record component of your
output will always be same length not 1 10 100 etc. but 00001,00010,00100
etc.

Public Function CalculateFindingNo(Val1 As String, Val2 As Date, RecNo As
Long) As String
CalculateFindingNo = Val1 & Val2 & Format(RecNo, "00000")
End Function

I suggest you start by removing vale2 and val3 from your code and then pass
in txtbox1 and check the result and then add txtbox2 and then recno etc.

Allan Murphy
Email: (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top