Solved

Bring up a screen to edit..

Posted on 2000-04-10
10
287 Views
Last Modified: 2010-05-18
Hola everyone again...

Same project differant problem, here goes:

I created a program that will help our IT staff track projects that are submitted (through this program) to a database.

Well the entry part is done, (as is all the database updating, report generating, query stuff....etc).

But now I am trying to code a lookup form.

I have an FlexGrid and if I click on my command button to show all projects entered, they come up in the grid.

Also, if a person enters in a name it searches the database and brings up the data on the Grid..

Now here is what I am lost on.
I want the person to be able to double click on one of the projects on the Grid, and then I want it to bring up the form that the project was entered on, so that it can be looked at or edited by the person who it is assigned to.

Like I stated, I can bring everything up into the FlexGrid, but I have no clue on how to bring up the form with the information included in it so that someone from IT can edit it.

HERE IS THE SEARCH FORM CODE:

Private Sub Command1_Click()
    SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS"
    Datctr.DatabaseName = gsDatabase
    Datctr.RecordSource = SQL
   
    Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
    Set Datctr.Recordset = PROJ
   
End Sub

Private Sub Form_load()

    KeyPreview = True
   
End Sub

Private Sub Continue_Click()
  'open_tables
   
    If it = "Sebastian" Then
    SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'Sebastian'"
    Datctr.DatabaseName = gsDatabase
    Datctr.RecordSource = SQL
   
    Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
    Set Datctr.Recordset = PROJ
       
    Else
        If it = "Pat" Then
        SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'Pat C'"
        Datctr.DatabaseName = gsDatabase
        Datctr.RecordSource = SQL
   
        Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
        Set Datctr.Recordset = PROJ
       
        Else
            If it = "John" Then
            SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'John'"
            Datctr.DatabaseName = gsDatabase
            Datctr.RecordSource = SQL
   
            Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
            Set Datctr.Recordset = PROJ
        Else
                If it = "New" Then
                SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'New'"
                Datctr.DatabaseName = gsDatabase
                Datctr.RecordSource = SQL
   
                Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
                Set Datctr.Recordset = PROJ
               
          Else
                    If it = "sebastian" Then
                    SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'Sebastian'"
                    Datctr.DatabaseName = gsDatabase
                    Datctr.RecordSource = SQL
   
                    Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
                    Set Datctr.Recordset = PROJ
         
          Else
                         If it = "john" Then
                         SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'John'"
                         Datctr.DatabaseName = gsDatabase
                         Datctr.RecordSource = SQL
   
                         Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
                         Set Datctr.Recordset = PROJ
           Else
                            If it = "pat" Then
                            SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'Pat C'"
                            Datctr.DatabaseName = gsDatabase
                            Datctr.RecordSource = SQL
   
                            Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
                            Set Datctr.Recordset = PROJ
               
           Else
                                 
                                 If it = "new" Then
                                 SQL = "SELECT [Project_num], [Date_Entered], [Requested_By], [Priority], [Assigned_to], [Date_Assigned], [Project_Status] FROM PROJECTS where assigned_to = 'New'"
                                 Datctr.DatabaseName = gsDatabase
                                 Datctr.RecordSource = SQL
                                 
                                 Set PROJ = GSDB.OpenRecordset(SQL, dbOpenDynaset)
                                 Set Datctr.Recordset = PROJ
           Else
                                 
                                 MsgBox ("Enter a valid IT Employee")
                                 it.Text = ""
                                 Exit Sub
          End If
           End If
              End If
                End If
                   End If
                    End If
                        End If
                          End If
         
        'grid.Col = 0
        'it.Text = Val(grid.Text)
       open_tables
     
       If it.Text = "" Then
           MsgBox ("Project Not Found, try again")
               Exit Sub
     
      End If
     
     
End Sub

Private Sub Exit_Click()
 
    Exit_check
   
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
 
   If KeyAscii = 13 Then
      Continue_Click
   End If
   
End Sub

Private Sub Insured_Gotfocus()

    SendKeys "{Home}+{End}"
   
End Sub

Private Sub Exit_check()

     Stmsgtext = "Are you sure you want to Close the Search Form" + "?"
     inoptions = vbQuestion + vbYesNo + vbDefaultButton2
     Stmsgtitle = "Exit Confirmation"
     inreturn = MsgBox(Stmsgtext, inoptions, Stmsgtitle)

     If inreturn = vbYes Then
        Screen.MousePointer = vbDefault
        Load Menu
        Menu.Show
        Unload Me
       
     End If
     
End Sub

Private Sub mnuItemGoBack_Click()

End Sub
Private Sub Grid_EnterCell()
     
    grid.CellForeColor = vbBlue
    grid.CellBackColor = vbGreen
    grid.CellFontBold = True

End Sub

Private Sub Grid_Leavecell()
   
    grid.CellForeColor = vbBlack
    grid.CellBackColor = vbWhite
    grid.CellFontBold = False
    grid.CellFontItalic = False
   
End Sub

Private Sub Grid_dblclick()
   
    open_project_click
   
End Sub

Private Sub open_project_click()

    grid.Col = 0
    G_Project_number = Val(grid.Text)
       
    open_tables
       
    setup_tables
   
End Sub

----------------------------------------
HERE IS THE OPEN_TABLES CODE:

Sub open_tables()
   
Set PROJ = GSDB.OpenRecordset("projects", dbOpenTable)
End Sub

----------------------------------------
HERE IS THE SETUP TABLES CODE:

???? THIS IS WHERE I HAVE NO CLUE ON WHAT TO DO..

----------------------------------------

Before anyone asks this is my first VB program, and I am teaching myself how to write it ( I am a Network Administrator by trade).. I know that there are better ways to write the Nested if  (such as using CASE etc..)


Any help would be greatful and if you could please elaborate on your answer, cause hey I am learning so it would be better for me to know...

Thanks
0
Comment
Question by:Jobber
  • 5
  • 4
10 Comments
 

Expert Comment

by:patm_EE
ID: 2701888
In The dblClick Method of the Flex Grid, You could use the FlexGrid.Text to determine the Key Field (I assume this is Project Number)

Create an SQL statement that will query the database and display the data on the Add/Edit screen.  

If a NEW item is being entered, set the global variable to ""

I can give you the code for this if necessary...
0
 
LVL 1

Expert Comment

by:olx
ID: 2701900
dunno if this will help you, but i hope so.

there's a little trick i use and it is very simple:

on the grid add the record number and hide the column
in the msflexgrid_dblclick:
record=me.msflexgrid.textmatrix(me.msflexgrid.row,(the hidden col))

and then you make visible the same form you actually use to capture the information.

- - - -

about the way to get the record into that form, plz tellme how you doit to get it from the capture form to the db, and ill tell you the rest.

salutez

0
 
LVL 1

Author Comment

by:Jobber
ID: 2701902
Yeah, if you don't want to do it here email me at: (send me the code)

sebastian.szachta@novacasualty.com

I knew that I had to determin the key (which yes it project number), but I have no clue how to get the screen back up. I am guessing I have to pass the form fields to the database fields, but being new to VB I have no clue how to do this.

0
 
LVL 1

Expert Comment

by:olx
ID: 2704052
it is not so difficult.

in  the data control where you did the capture set the recordset to a sql query to match only the record you want and then make it visible.

:)
0
 
LVL 1

Expert Comment

by:olx
ID: 2704062
obviously the textboxes have the datasource property set to the name of the datacontrol.
as soon as you set the recordset, the textboxes will have the info you need.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Author Comment

by:Jobber
ID: 2704091
Sorry to sound so stupid, but could you give me an example of what the code would look like
0
 
LVL 1

Accepted Solution

by:
olx earned 250 total points
ID: 2706449
plz give me the name of the datacontrol you used in the form you typed the data,
the name of the form, and the name of the grid where you have the query.
ill give you the code.

:)
0
 
LVL 1

Author Comment

by:Jobber
ID: 2708013
Adjusted points from 151 to 250
0
 
LVL 1

Author Comment

by:Jobber
ID: 2708014
Thanks for all of the help that you gave me...
0
 
LVL 1

Expert Comment

by:olx
ID: 2713446
thank you Jobber
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now