combo box clearing after entry

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

Thanks Hans, i am off to bed now, i will investigate further in the morning.

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

HansV wrote:
Pat wrote:Yes i can edit that field, i can also add a record in the query too.
I am very sorry, but I fear I can't solve the problem of the combo box for you.
I dont know if this helps but it is an Access 2003 FE to a SQL Server 2005 Express BE.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: combo box clearing after entry

Post by HansV »

If I could, I would dearly like to help, but I really don't know what causes this problem.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

Thanks Hans, I have decided to go back to a database before I started all these changes. I will save the database after every change and see what change does it.

I appreciate your insights and help. I'll keep you posted.

A question here though, I notice that the original query had fields from 2 tables that were populating the form's controls, what happens if you try to add a record with these 2 tables, will it create an entry in each table,or do i need special code in the Form_AfterUpdate to do this?

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: combo box clearing after entry

Post by HansV »

It depends on the exact structure of the query, and that the tables are in a SQL Server database may also play a role, so I'd experiment - go to a new record in the form and enter some values in fields from both tables, then close the form and go to the tables to see what happened...
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

The reason i got into this pickle is that i inherited this database from 3 developers before me, they had code in there that i thought i had better use, silly me. I am now going to ignore what they have done.

I went right back to the database on 9/7/10 and viola, it writes 2 records one to each table.

I now have a good starting point.

Thanks for your patience and time Hans, it really is great having people to bounce these things off.

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

With this coding above, can I get the file title as you can in the common dialog code?

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: combo box clearing after entry

Post by HansV »

In the common dialog, FileTitle returns the name of the selected file without the path. There is no separate property for that in FileDialog, but you can easily extract it from the full name:

Code: Select all

  Dim strFile As String
  Dim intPos As Integer
  Dim strName As String
  With Application.FileDialog(msoFileDialogOpen)
    .Filters.Clear
    .Filters.Add "Text files", "*.txt"
    If .Show = True Then
      strFile = .SelectedItems(1)
    Else
      MsgBox "No file selected!", vbExclamation
      Exit Sub
    End If
  End With
  ' Extract the file name from the full name
  intPos = InStrRev(strFile, "\")
  strName = Mid(strFile, intPos + 1)
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: combo box clearing after entry

Post by Pat »

I misunderstood what the title meant.
That's easy eh.
Thank you.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: combo box clearing after entry

Post by HansV »

If you want to set the title (caption) of the dialog window, use the Title property. You can also customize the caption of the main button in the dialog by setting the ButtonName property:

Code: Select all

  With Application.FileDialog(msoFileDialogOpen)
    .Title = "Please select a file"
    .ButtonName = "Click Here"
    ...
Best wishes,
Hans