Control Code to set a Date

B

Bob V

My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment] which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the date im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 
B

Biz Enhancer

Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick
 
B

Bob V

Biz How Brilliant is that Thanks going to find out how to learn to code Dim
x..................Thanks Bob
Biz Enhancer said:
Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick

Bob V said:
My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment]
which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the date
im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 
B

Biz Enhancer

Hi Bob,

The Dim Statement is simply declaring that variable "x" is a string. The "x"
can be replaced with anything as long as later in the code the reference is
to the variable. e.g.
Dim banana as integer
banana = 5

Declaring variables is a really powerful way to reuse code and to minimise
the amount of coding when in a loop statement (among other things).

Once I started to understand them my coding ability really started to take
off.

Glad to have been some use.

Regards,
Nick.

Bob V said:
Biz How Brilliant is that Thanks going to find out how to learn to code Dim
x..................Thanks Bob
Biz Enhancer said:
Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick

Bob V said:
My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment]
which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the date
im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 
B

Bob V

Nick, Can I put an error Message In if no selection is made
If cbOwnerName.value = "" Or IsNull(cbOwnerName.value) Then
MsgBox "You have not made a Selection!", vbApplicationModal +
vbOKOnly + vbInformation
Exit Sub
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub
Thanks for your Help...Bob

Biz Enhancer said:
Hi Bob,

The Dim Statement is simply declaring that variable "x" is a string. The
"x"
can be replaced with anything as long as later in the code the reference
is
to the variable. e.g.
Dim banana as integer
banana = 5

Declaring variables is a really powerful way to reuse code and to minimise
the amount of coding when in a loop statement (among other things).

Once I started to understand them my coding ability really started to take
off.

Glad to have been some use.

Regards,
Nick.

Bob V said:
Biz How Brilliant is that Thanks going to find out how to learn to code
Dim
x..................Thanks Bob
Biz Enhancer said:
Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick

:

My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment]
which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the
date
im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 
B

Bob V

Nick, Got Column(1) working great , but having trouble with Column(8), I
have commered it out for the moment
Thanks for any Help.Bob

Private Sub cmdLastPay_Click()
If cbOwnerName.Column(1) = "" Or IsNull(cbOwnerName.Column(1)) Then
MsgBox "Please Make a Selection!", vbApplicationModal + vbOKOnly +
vbInformation
Exit Sub
'If cbOwnerName.Column(8) = "" Or IsNull(cbOwnerName.Column(8)) Then
'MsgBox "No Last Payment!", vbApplicationModal + vbOKOnly +
vbInformation
'Exit Sub
End If

Dim X As String

X = Me.cbOwnerName.Column(8)
Me.tbDateFrom = X

'End If

End Sub
Bob V said:
Nick, Can I put an error Message In if no selection is made
If cbOwnerName.value = "" Or IsNull(cbOwnerName.value) Then
MsgBox "You have not made a Selection!", vbApplicationModal +
vbOKOnly + vbInformation
Exit Sub
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub
Thanks for your Help...Bob

Biz Enhancer said:
Hi Bob,

The Dim Statement is simply declaring that variable "x" is a string. The
"x"
can be replaced with anything as long as later in the code the reference
is
to the variable. e.g.
Dim banana as integer
banana = 5

Declaring variables is a really powerful way to reuse code and to
minimise
the amount of coding when in a loop statement (among other things).

Once I started to understand them my coding ability really started to
take
off.

Glad to have been some use.

Regards,
Nick.

Bob V said:
Biz How Brilliant is that Thanks going to find out how to learn to code
Dim
x..................Thanks Bob
Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick

:

My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment]
which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the
date
im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 
J

John W. Vinson

Nick, Got Column(1) working great , but having trouble with Column(8), I
have commered it out for the moment

Note that Column(8) is the *ninth* field in the rowsource query - the property
is zero based. Doublecheck that you're getting the correct field!

John W. Vinson [MVP]
 
B

Biz Enhancer

Hi Bob,
A little juggling on the order of code might help.

Private Sub cmdLastPay_Click()
Dim x As String, y as string
y = Me.cbOwnerName.Column(1)
x = Me.cbOwnerName.Column(8)

If IsNull(y) Or y = "" Then
MsgBox "Please Make a Selection!", vbApplicationModal + vbOKOnly +
vbInformation
Goto Exittrp
Else
If IsNull(x) Or x = "" Then
MsgBox "No Last Payment!", vbApplicationModal + vbOKOnly +
vbInformation
Goto Exittrp
End if
End if
Me.tbDateFrom = X
Exittrp:
Exit Sub

End Sub

Nesting the If statements allows checking of the first statement and then
checking the second condition. Putting the GoTo statement in, make the code
jump to a certain point bypassing any other code that doesn't need to be run.

Regards,

Nick.

Bob V said:
Nick, Got Column(1) working great , but having trouble with Column(8), I
have commered it out for the moment
Thanks for any Help.Bob

Private Sub cmdLastPay_Click()
If cbOwnerName.Column(1) = "" Or IsNull(cbOwnerName.Column(1)) Then
MsgBox "Please Make a Selection!", vbApplicationModal + vbOKOnly +
vbInformation
Exit Sub
'If cbOwnerName.Column(8) = "" Or IsNull(cbOwnerName.Column(8)) Then
'MsgBox "No Last Payment!", vbApplicationModal + vbOKOnly +
vbInformation
'Exit Sub
End If

Dim X As String

X = Me.cbOwnerName.Column(8)
Me.tbDateFrom = X

'End If

End Sub
Bob V said:
Nick, Can I put an error Message In if no selection is made
If cbOwnerName.value = "" Or IsNull(cbOwnerName.value) Then
MsgBox "You have not made a Selection!", vbApplicationModal +
vbOKOnly + vbInformation
Exit Sub
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub
Thanks for your Help...Bob

Biz Enhancer said:
Hi Bob,

The Dim Statement is simply declaring that variable "x" is a string. The
"x"
can be replaced with anything as long as later in the code the reference
is
to the variable. e.g.
Dim banana as integer
banana = 5

Declaring variables is a really powerful way to reuse code and to
minimise
the amount of coding when in a loop statement (among other things).

Once I started to understand them my coding ability really started to
take
off.

Glad to have been some use.

Regards,
Nick.

:

Biz How Brilliant is that Thanks going to find out how to learn to code
Dim
x..................Thanks Bob
Hi Bob,
If I am understanding correctly this should solve your problem.

"OnClick" event
Sub Command1_Click()
Dim x as string

x = me.cbOwnerName.Column(8)
me.tbStartDate = x

End Sub

HTH,
Nick

:

My Combo Box [cbOwnerName] has a Row Source [qPayableTotalForPayment]
which
has 9 Columns in combo box the last Column being
[My Date]MyDate: Format([MaxOfBillDate],"d-mmm-yy")
I want to code my Button to Change the date in [tbStartDate] to the
date
im
[cbOwnerName] once selected I click Button to give that date in
[tbStartDate]
Thanks for any help.........Bob
 

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