How to create an indexed field (Duplicates OK) using VBA

I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
Regards, Jim
Sub AddFldSect4_4()
Call FieldExists("DisplayOrder", "Section4_4")
End Sub
Function FieldExists(ByVal fieldName As String, ByVal tableName As String) As Boolean
Const gcfHandleErrors As Boolean = True
If gcfHandleErrors Then On Error GoTo Error_Handler
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim strName As String
Set db = CurrentDb
Set tbl = db.TableDefs(tableName)
For Each fld In tbl.Fields
If fld.Name = fieldName Then
FieldExists = True
Exit For
End If
Next
If FieldExists = False Then
Call addColumn(tableName, fieldName)
End If
Error_Handler_Exit:
On Error Resume Next
Exit Function
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
"Error Number: " & err.Number & vbCrLf & _
"Error Source: Field Exist" & vbCrLf & _
"Error Description: " & err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
Public Sub addColumn(tableName As String, fieldName As String)
Const gcfHandleErrors As Boolean = True
If gcfHandleErrors Then On Error GoTo Error_Handler
Dim strField As String
Dim curDatabase As Object
Dim tblTest As Object
Dim fldNew As Object
Set curDatabase = CurrentDb
Set tblTest = curDatabase.TableDefs(tableName)
strField = fieldName
Set fldNew = tblTest.CreateField(strField, dbInteger)
tblTest.Fields.Append fldNew
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
"Error Number: " & err.Number & vbCrLf & _
"Error Source: Add Col" & vbCrLf & _
"Error Description: " & err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Sub
jim neal

I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
Hi Jim,
I give you a couple of examples that I use to create or delete indexes. They are "heavily parametrized", so they can be used for every table using any fields. Study your Help for further information on "Create Index", and others.
tmp_db.Execute "CREATE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_type & ")" & " WITH PRIMARY" tmp_db.Execute "CREATE UNIQUE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_velden & ")" '& " WITH PRIMARY" tmp_db.Execute "DROP INDEX " & cur_keynaam & " ON " & cur_item & "_tbl"
tmp_db stands for the BE-database; cur_item & "_tbl" represents the table name.
Imb.

Similar Messages

  • How to create secondry index on database table

    how to create secondry index on database table

    Hi
    By trx SE11:
    - Choose your table and press CHANGE ICON, so INDEX
    When you create an index you should consider if your index is contained in another index.
    If the fields of your index are:
    - FIELD1, FLIED2, FIELD3
    ...it'll be triggered only if the select is:
    SELECT * FROM <TABLE> WHERE FIELD1
                            AND FIELD2
                            AND FIELD3
    A select like this
    SELECT * FROM <TABLE> WHERE FIELD1
                            AND FIELD3
                            AND FIELD2
    doesn't use your index.
    Max

  • How to create Secondary Index?

    Hello All
    Can anyone let me know how to create secondary indexes?
    I hope Primary Indexes are being created automatically?V can'nt able to create this.
    regards
    balji

    Hi,
    1) Go to Se11 select table /BI0/A<ODS>00 > Utilities> Data bse Object --> Check.
    2) If you are using ODS Active table in any Start routine ,Make sure that the order of objects to be seleccted (select statement) should be in same order of index fields.
    In Query, Use RSRT to know the SQL statement of the Query .and follow same logic explained above.
    3) No need to create Secondary Index for Cube.
    4) IT recreates the Index.
    With rgds,
    Anil Kumar Sharma .P

  • How to create secondry index

    Any body help me.please tell me how to create secondry index.
    Thanks & Regards,
    Rakesh

    Hi
    Goto SE11 and give the table name
    then click on Indexes which is in application toolbar
    then on that dialog box click on CREATE
    then give a name for ur index starting with Y or Z
    then select the fields from that table for indexes.
    then save in package
    then activate it
    thats all
    follw the above steps for creating.
    If helpful reward points
    Regards
    Navneet

  • How to create a index in TREX

    Hi Experts.
    I am just a beginner in portals......
    Please float ur step by step approach on
    How to create a index in TREX?
    If anybody has document for this topic pls send it to [email protected]
    Thanks in Advance,
    Jasmine

    Hi Jasmine,
    1. Go to System Administration -> System Configuration -> Knowledge Management -> Index Administration
    2. Choose "Create".
    3. Read the SAP Help Documentation to see a description of the fields the you have to entry: http://help.sap.com/saphelp_nw2004s/helpdata/en/73/66c090acf611d5993700508b6b8b11/frameset.htm
    4. After the new index is assign a data source to the index as described here: http://help.sap.com/saphelp_nw2004s/helpdata/en/73/66c093acf611d5993700508b6b8b11/frameset.htm
    5. After saving the index the crawling should start and shortly you should be able to search for documents.
    Hope this helps,
    Robert

  • How to create a new field for Q3 - QM notification in Header and item level

    Dear All,
    l
               Sub: How to create a new field for Q3 - QM notification in Header and item level
    Ref. the link --> Quality Notification
    We want to create a new field in header level and item level.
    As per the thread the solution is given below.
    In the IMG Config: Quality Management -> Quality Notification -> Notification Types -> Define screen areas for notification types Then Choose 'Define screen areas' Then Click on 'New entries' button Now, select the relevant Notification Type and click in 'Enter'. Select the 'Iten Cases' register and remember to setup the Tabstrip Header, Icon, etc. Set the 'Tabstrip active' flag. Then Save.
    Quality Notification -> Notification Types -> Define screen areas for notification types
    WE ARE UNABLE TO FIND IN CUSTOMIZATION PATH --> DEFINE SCREEN AREAS FOR NOTIFICATION TYPES.
    Please help.
    Question No. 2 :
    THE REQUIREMENT IS GIVEN BELOW.
    We want to hide the field in Q3 - QM Notification
    In header --> Reference tab --> Item (sub heading) --> "DEFECT LOCATION" FIELD TO BE ELIMINATED (HIDE)
    Ref the link --> Quality notification
    The solutiion is given below.
    Hi Sami,
    We can hide the collumns using the Transaction OQM1 and Program Name SAPLIQS0.
    Lets say Defect location need to be hidden, the field TXTCDOT need to have the radio button HIDE.
    Hope this will suffice your requirement.
    Kindly ask me if you need any other details.
    Thanks & Regards,
    Srinivas.D
    Hi Sami,
    We can hide the collumns using the Transaction OQM1 and Program Name SAPLIQS0.
    Lets say Defect location need to be hidden, the field TXTCDOT need to have the radio button HIDE.
    Hope this will suffice your requirement.
    Kindly ask me if you need any other details.
    Thanks & Regards,
    Srinivas.D
    By double clicking the "DEFECTIVE QUANTITY (EXTERNAL), WE COULD NOT GET --> field TXTCDOT .
    Plese do the needful.
    We are using ECC6.0 Ehp3 and Ehp4.
    With Best Regards,
    Raghu Sharma

    Dear Pushpa,
    Transaction Code :SHD0 is working fine.
    Please accept my sincere thanks for your sharing your Knowledge.
    I am able to fulfill my
    Regarding the enhancement, I have not tried.
    Once I will complete, I will award the fulll marks to you.
    With Best Regards,
    Raghu Sharma

  • How to create a new field in a sub screen in material master. ?

    How to create a new field in a sub screen in material master. ?
    Kindly help us.
    LIke wise tell me how to create a new sub screen as per my desired

    Follow the documentation of Logistics - General->Material Master->Configuring the Material Master->Create Program for Customized Subscreens  to add the new field in material master.
    Create Program for Customized Subscreens
    In this IMG activity, you can create a function group of your own by copying function group MGD1 (for industry) or function group MGD2 (for retail). The subscreens are not copied, except for two subscreens which are copied for technical reasons. You can use this copy to create subscreens of your own which you can assign to a data screen in the activity Define Structure of Data Screens for Each Screen Sequence.
    Requirements
    Be sure to read the program documentation first.
    Activities
    1. Create a function group of your own by choosing Execute.
    2. Enter a name containing up to 25 characters, beginning with the letter Y or Z, and choose Save.
    3. Access the Object Navigator.
    You do this from the SAP standard menu by choosing Tools -> ABAP Workbench, and then Object Navigator.
    4. Display either program SAPLMGD1 (industry) or SAPLMGD2 (retail) as required.
    5. Copy the subscreens as required, ensuring that they already contain as many as possible of the field names you want to use in your function group. You do this as follows:
    a) Choose Screens, position the cursor on the corresponding subscreen, and choose Copy in the context menu.
    b) Enter the program to which you want to copy the subscreen, prefixing it with SAPL, and enter a screen number. Use the screen number of the original subscreen where possible. If the F1 help is specific to a particular subscreen, this ensures that this context-specific help continues to be displayed.
    Example
    You have called your function group YENTERPRISE, to which you want to copy subscreen SAPLMGD1 2301. Enter SAPLYENTERPRISE as the program to which the subscreen is to be copied, and enter (preferably) 2301 as the screen number.
    6. Return to the initial screen of the Object Navigator and display your program. In the example above, you would enter SAPLYENTERPRISE.
    7. Choose Update object list.
    8. Select the subscreen you have copied and activate it by choosing Activate in the context menu.
    Using the Screen Painter, you can remove fields you do not require on the subscreen or include additional fields from other subscreens (see the ABAP Dictionary). For information on the Screen Painter, see the SAP library documentation BC ABAP Workbench Tools.
    Points to consider when removing or adding fields
    Make sure that a field statement exists for each field on the subscreen since data may not otherwise be transported correctly. You can use subscreen SAPLMGD1 2002 as an example.
    For the fields you have added, include any check modules and modules for self-programmed F4 help that are called up for these fields on the original subscreen. You can do this by displaying the flow logic for the original subscreen and searching for such modules. They normally have the same names as the fields themselves. When you find a module, copy the corresponding module call to your subscreen.
    If you change the order in which fields are transported that are checked together in the flow logic (such as the safety stock and minimum safety stock), you must deactivate the check module for the first field and activate it for the second. The system would otherwise transport the first field, and carry out the check before the second field is transported.
    Any error messages that fields are unknown when activating the subscreen are due to the fields still being included in checks, even though you have removed the fields from the subscreen. Search for the fields in the source code and make the lines in which they appear comment lines. Then reactivate the screen.
    9. Assign the subscreen to a data screen as required.
    Note on transport
    Use the Workbench Organizer to transport the copy you have created.
    Proceed

  • Quick Tip: How to create editable form fields | Acrobat X Tips & Tricks | Adobe TV

    A short tip that details how to create editable form fields using Acrobat X Std. or Pro.
    http://adobe.ly/wzXkmL

    I have created a form which will be filled out by customers and sent back to me via 'submit' button. What I am trying to figure out is when we receive the filled out form, is there any way to have it as a pdf. To clarify, when the form is filled out and sent, the receiver opens the email and attached is a non-editable pdf. This way the customers information is no longer editable.

  • How to create a Index for KM documents

    Hi Experts.......
    I have two queries .
    1,How to create a Index for the KM Server documents so that when ever i am in need of particular document,i can be able to retrive the exact document within short time......
    2,What Is TREX? Need of TREX ?
    If any one have documents for the above said queries kindly send it to [email protected]
    Thanks in Advance,
    Jasmine

    Hi Jasmine,
    1.In the EP 6.0 you can create index System Administration -> System Configuration -> Knowledge Management -> Index Administration
    2.TREX is search engine that will proccess the documents that you have specified in the index Data sources when you have created the index.
    The status of TREX you can see in System Administration -> Monitoring -> Knowledge Management -> TREX Monitor or Index Monitor for indexing monitoring.
    If you don't have connected any TREX engine to J2EE, just start the visual administrator and configure the TREX service.
    To install the TREX you can follow the instguides for TREX service.sap.com/instguides SAP Netweaver->Release 04 or 2004s -> Installation -> Cross-NW
    I hope that it helps.
    Bye
    Dan

  • How to create a scenarios for duplicate entries

    Hi friends,
    Please help me how to create a scenarios for duplicate entries, we are using stock transfer orders from there we need to create scenarios for duplicate entries, please guide me on the same.

    Hi,
    F-01 can be used to create a sample document.
    Regards
    Aditya

  • How to create a calculated field

    Hi. I'd like to know how to create a calculated field for a master- detail form. For example: having two db fields price and quantity, i created a the total item (price * quantity) as pl/sql function like this:
    begin
    :p13_item_total := :p13_price * :p13_quantity;
    end;
    However, the item is not calculated. It is not and instant calculation. I mean if i modify either price or quantity, how to recalculate item total immediately

    You must submit the page to do it with PL/SQL. If you do not want to submit the page, you must do it with JavaScript.
    Thanks,
    Tyler

  • How to create a new field

    how to create a new field form se 38 and update it to the customized table in the se11. I have done modification insertion deletion and update of field values in se 38 and has updated to the table in se 11. I want to know how to create a table from se38 and update it to the table in se11.I dont know whether it is possible. Enlight me.
    with regards,
    SREERAM M

    Hi:
    have a look
    [Link1|http://www.wiziq.com/tutorial/17782-SAP-BDC-File-Handling]
    [Link2|http://www.sap-img.com/abap/learning-bdc-programming.htm]
    Regards
    Shashi

  • How to create tab indexing for jtextBox

    Dear Forum
    i am user of jDeveloper.
    And working on JClient/Swing application.
    In "Jframe.java" i add various cotrols such as jTextbox,jCombobox ,jlabel etc.
    So how to create tab indexing for these controls.
    Girdher

    Dear Forum
    i am user of jDeveloper.
    And working on JClient/Swing application.
    In "Jframe.java" i add various cotrols such as jTextbox,jCombobox ,jlabel etc.
    So how to create tab indexing for these controls.
    Girdher

  • How to Create the new Field ( Table - Row) in SAP B1

    I have a scenario in which the Purchase calculation is based on LR, so for that we have to add new field in Purchase  Document. that filed is not available in form setting.  kindly let me know how to Create a new field in Purchase document.
    Thanks

    Hi,
    I have adding new & existing forms and creating User Defined Field in row. example on adding a field in an existing Form and its corresponding to the database, including user input validations?
    I want to add a new field in the detail section ( row area ) of a Production Document, and save it to database and read it back when the document is opened.
    Thanks.
    Syed Waqar Khurshid

  • How to create a index on a column with type clob

    how to create a index on a column with type clob

    You should have a look to Oracle Text to check if Oracle Text indexing features can meet your needs:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/cncptdev.htm#CNCPT1537

Maybe you are looking for

  • How to Clear a A/R GL with Huge line items

    Hi All, Could you please suggest a way to solve this issue: A/R GL which has more than 90 Million open line items.  We want to clear all the open items in this GL account.  Also we use back ground job for program SAPF124 for clearing open items.  We

  • No menu option for Review Acrobat 9

    I haev Acrobat Pro 9 on a windows XP machine.  I had previously created PDF from MS Word documents and sent them for shared review with no problem. Today, I do not have the option int he file menu to initiate this process anymore. Does anyone know wh

  • How do I get the adjustment brush to "paint" white?

    How do I get the adjustment brush to "paint" white? I have tried the  color panel, but nothing works.

  • Why Labview.ex​e error when exit simple-sta​te machine?

    Can someone please help me figure out why, unless I ABORT the VI, I get a "Labview.exe is closing" error when I press Stop. I am using a simple-state machine like what comes with Labview's examples. What could be some causes of this? I have read that

  • Delivery against advance received

    Hi SAP Experts, Please help me on this issues: My client wants, to deliver goods only if the advance payment for the same is received, otherwise delivery should be blocked. How to configure this? All the deliveries are processed against quantity Cont