I'm trying to add a field to an existing database with a run date keyed in by the user
I'm getting the following error "Error on line 26 - type mismatch"
Does anyone have the answer - The code is as follows:
Sub Main Call TestFunc2() ' Test different coding examplesEnd Sub
Function TestFunc2' Create the input for Run Date Dim RunDate As Date RunDate = InputBox("Enter Run Date MM/DD/YYYY", "Run Date", "") ' Open the database. Set db = Client.OpenDatabase("Current_Period.IMD") ' Display the result. MsgBox "Run Date: " & RunDate ' Create the task. Set Mgt = db.TableManagement ' Obtain a reference to the table. Set ThisTable = db.TableDef ' Create a new field. Set FirstField = ThisTable.NewField ' Configure a new field. FirstField.Name = "AsOfDate" FirstField Description = "As of Date" FirstField.Type = WI_DATE_FIELD FirstField.Equation = RunDate FirstField.Length = 10 ' Add the field. Mgt.AppendField Field 'This is Line 26 Mgt PerformTask Set Mgt = db.TableManagementEnd Function
Last seen: 5 years 3 months ago
Joined: 01/25/2017 - 09:24
I see 2 issues in the code.
1) You are getting "Type Mismatch" error because you are using a different object variable "Field" instead of using the defined object variable "FirstField" in the line "Mgt.AppendField Field"
2) You have to convert the input date string to date using@Ctod function
Attached the modified code.
Can you also help me, what changes will be made in the above file"date issue.iss" if its a numeric field?
That would depend if the numeric field has decimals or not.
Yes, It has up to 2 decimals.