help wanted, calculated field (1 Viewer)

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
Hello all,

I am seeking help with a format for a calculated field which can be seen in the attachments

I use the calculation [field1] & [field2] & [field3] & [field4] & [field5]
field 1 is a number, field 2 is a date, field 3,4 and 5 are numbers.

The calculated field displays the following format
1/1/1/2015/2/3/4
with a format @\/@@@@@@@@@\/@\/@\/@
:banghead:

The format that I would like to display in my calculated field is
1/010115/2/3/4

1 being the field 1 number,
010115 being the date ddmmyy,
2 (field3)
3 (field4)
4 (field5)


Many thanks in advance!
 

Attachments

  • charge.PNG
    charge.PNG
    4.5 KB · Views: 83
  • charge2.PNG
    charge2.PNG
    6.5 KB · Views: 83

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
Hello,

Thank you for the reply,

where do I insert that now in so that I can create the desired format?

Sorry I am a total newbie
 

plog

Banishment Pending
Local time
Yesterday, 20:36
Joined
May 11, 2011
Messages
11,669
I use the calculation [field1] & [field2] & [field3] & [field4] & [field5]

Substitute it for the appropriate field in the above.
 

cyanidem

Nieóhfytny jaszczomp
Local time
Today, 02:36
Joined
Nov 30, 2015
Messages
106
Specifically what you want is this:

Format([YourDateField],"ddmmyyyy")

I think he actually needs
Code:
Format([YourDateField],"ddmmyy")
So calculation will look like:
Code:
[field1] & Format([YourDateField],"ddmmyy") & [field3] & [field4] & [field5]
 

plog

Banishment Pending
Local time
Yesterday, 20:36
Joined
May 11, 2011
Messages
11,669
The format that I would like to display in my calculated field is
1/010115/2/3/4

cyan is right.
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
what if I would like to make a button on a form in VBA that when clicked would generate the same combination in a text box field, which data will then be stored in my table.

could you guys please help me with the code?

The format that I would like to display in the combined text box is
1/010115/2/3/4

(field1)
(field2) 010115 being the date ddmmyy,
field3)
(field4)
field5)

combined box from the 5 fields.

if I make combined box = field1 +"/" + field2 "+" field3.....
doesnt work,

could someone please tell me how?

many thanks in advance.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
combined box = (field1 + "/") & (field2 + "/") & (field3 + "/") & (field4 + "/") & (field5)
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
thank you,

One more question,
how can I then formate the date in VBA to be displayed as a number value in the combined box calculation that you have posted?
like 01/02/15 , by 01 being the day, 02, being the month and 15 being the year.
field 2 being formatted from 2/1/2015 to 020115 in the combined box.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
combined box = (field1 + "/") & Format(field2, "ddmmyy\/") & (field3 + "/") & (field4 + "/") & (field5)
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
Private Sub btnCharge_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim resoult As Integer
a = Me.cmbProduktgruppeID
b = Me.txtChargeDatum
c = Me.cmbLinie
d = Me.cmbAbfulung
e = Me.cmbExtruder
resoult = (a + "/") & Format(b, "ddmmyy\/") & (c + "/") & (d + "/") & (e)
Me.txtcharge2 = resoult
End Sub


this now shows me a msg that says overflow, and it points to the b = Me.txtChargeDatum

all the problems I have at the moment are because of the damn datum...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
hehe, your funny.
what is the value of Me.txtChargeDatum, is it date or numeric?
because in your btnCharge_Click, you declared it as Integer:

dim b As Integer

declare it as variant, then cast it as Date

Dim b As Variant

b = Me.txtChargeDatum
b = CDate(b)

remember to declare the correct datatype as with your control. if your control holds integer then declare it as such.
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
I am sorry for all the questions, but thank you for your help....
I am completely new to vba hope u understand...

now the message shows me run time error 13, type mismatch...:banghead:

attached the file.
 

Attachments

  • vba.PNG
    vba.PNG
    28.7 KB · Views: 65

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
remove the line, and see what happens. we already declare it as variant, i think it will not complain now.
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
still shows the error even if I rewrite it
 

Attachments

  • aaa.PNG
    aaa.PNG
    16.2 KB · Views: 76

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
remove this line:

b = CDate(b)
 

AljayB

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 2, 2015
Messages
19
still shows the same error even when I removed the line.

b = Me.txtChargeDatum is a date in my table.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,246
is it possible for you to upload your db.
 

Users who are viewing this thread

Top Bottom