New Db building stuff
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New Db building stuff
Context menu is right-click menu.
Move the mouse pointer to the column header of the ID column. the mouse pointer should change to a downwards arrow, indicating that you'll select the entire column.
Then right-click.
Move the mouse pointer to the column header of the ID column. the mouse pointer should change to a downwards arrow, indicating that you'll select the entire column.
Then right-click.
You do not have the required permissions to view the files attached to this post.
Regards,
Hans
Hans
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
To get around the error encountered when in putting a string into a number field, I built a new table and created a form with code. This is my scheme when the field ActionName has had an entry, there is an event code:
Now I enter string that will be converted to a number, for input to the Price field into the text box.
This leads me to:
I am using Access 20007 and split is not one of the functions that it recognizes. So I inserted a left and right function: Anyone, including myself figures that this will not work, So what would be the code steps to get Convert2Num () to work and have a finished number to input into the main price field, now if the new table field needs to be renamed that is ok, I plan for the table to one have one record, over and over again. I hope I have described this well enough. This would be an execution across two tables.
Code: Select all
Private Sub ActionID_AfterUpdate()
If Me.ActionID = 46 Then
Me.ActionName = "Buy to Open"
ElseIf Me.ActionID = 47 Then
Me.ActionName = "Buy to Close"
ElseIf Me.ActionID = 48 Then
Me.ActionName = "Sell to Open"Private Sub RawPrice_AfterUpdate()
Me.Price = Convert2Num(Me.Price)
End Sub
ElseIf Me.ActionID = 49 Then
Me.ActionName = "Sell to Close"
ElseIf Me.ActionID = 99 Then
Me.ActionID = "Other"
Else
MsgBox "You must enter a valid number", vbInformation
Cancel = True
End If
Me.Price.SetFocus
DoCmd.OpenForm "frmFracCalculator", acFormDS
'DoCmd.OpenForm "frmTrades", acFormDS
'Private Sub Price_AfterUpdate()
Me.Price = Convert2Num(Me.Price)
End Sub
Code: Select all
Private Sub RawPrice_AfterUpdate()
Me.Price = Convert2Num(Me.Price)
End Sub
Code: Select all
Function Convert2Num(Price As Variant)
Dim arr() As String, arrL() As String, arrR() As String
'If IsNull(Price) Then
' Convert2Num = Null
'Else
arrL(0) = Left(RawPrice, 3)
arrR(0) = Right(RawPrice, Len(RawPrice) - 4)
'If UBound(arr) = 0 Then
Convert2Num = CDbl(arrL(0))
'Else
Convert2Num = arrL(0) + arrR(0) / 32
'End If
arr(0) = arrL(0) + arrR(0) / 32
'End If
End Function
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New Db building stuff
Split should work in Access 2007. What is the error message that you get if you try to use it?
Regards,
Hans
Hans
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
Maybe it will, but the above code pieces go to the suc convert2Num prior to entering anything into the raw price and therefore is a null. I need it to go to the sub after entering a string into RawPrice, and after the number is calculated, I'll need to delete record 1 prior to sending the number back to to the main file.
You do not have the required permissions to view the files attached to this post.
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
ETA:I see the problem its my cidingbknight wrote: ↑30 Jan 2023, 18:09Maybe it will, but the above code pieces go to the suc convert2Num prior to entering anything into the raw price and therefore is a null. I need it to go to the sub after entering a string into RawPrice, and after the number is calculated, I'll need to delete record 1 prior to sending the number back to to the main file.
If Me.Symbol = "TY" Or Me.Symbol = "US" Then
Me.Price = Convert2Num(Me.Price)
End If
I need this to point back to Me.RawPrice instead of going to the convert sub, I'll try that. No need to reply.
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
This doesn't work
Control of the code still goes to the convert sub without using the PriceCalulation table.
ETA:
This ends with "Object required" error. I need a method of__> RawPrice to have focus to input that string 2 number.
Code: Select all
If Me.Symbol = "TY" Or Me.Symbol = "US" Then
frmPriceCalculation.RawPrice = Convert2Num(Me.Price)
End If
ETA:
Code: Select all
If Me.Symbol = "TY" Or Me.Symbol = "US" Then
'frmPriceCalculation.RawPrice = Convert2Num(Me.Price)
With frmFracCalculator.RawPrice
.SetFocus
End With
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
OK, then lets try this
Me.Price = some function to convert 114'14.5 to, of course 114+14.5/32. But not a whole sub. There is the string 114'14.5 in Me.RawPrice.
Me.Price = some function to convert 114'14.5 to, of course 114+14.5/32. But not a whole sub. There is the string 114'14.5 in Me.RawPrice.
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New Db building stuff
Does this work for you?
Use like this:
or in the Control Source of Price:
Code: Select all
Function Convert2Num(Price As Variant)
Dim p As Long
If IsNull(Price) Then
Convert2Num = Null
Else
p = InStr(Price, "'")
Convert2Num = Left(Price, p - 1) + Mid(Price, p + 1) / 32
End If
End Function
Code: Select all
Me.Price = Convert2Num(Me.RawPrice)
Code: Select all
=Convert2Num([RawPrice])
Regards,
Hans
Hans
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
Remember Me.price in the old table/form is a number and that is where the error came when trying to input a string. I'm assuming and you know what that means, Me.Price is in the original table, which is a double field and that is where the conversion failed. If you mean in the new table, I'll give it a whirl
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
Winner, winner chicken dinner. Into the second table, no go still in the first
Now what would be the command to delete a possibly dirty record or a the first/last record?
Now what would be the command to delete a possibly dirty record or a the first/last record?
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
One that still has the little pen/pencil in the left hand margin.
-
- Administrator
- Posts: 76214
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: New Db building stuff
The first record:
The last record:
A dirty record:
Code: Select all
RunCommand acCmdRecordsGoToFirst
RunCommand acCmdDeleteRecord
Code: Select all
RunCommand acCmdRecordsGoToLast
RunCommand acCmdDeleteRecord
Code: Select all
If Me.Dirty Then RunCommand acCmdDeleteRecord
Regards,
Hans
Hans
-
- 5StarLounger
- Posts: 1067
- Joined: 08 Jul 2016, 18:53
Re: New Db building stuff
If Me.Dity gives an error: "The command or action 'deleterord' isn't available now. Since it has the dirty pencil/pen, I would have to say a record can't be deleted until/unless it is in the recorset. So, I'll put aside the delete record.
Thanks
Thanks