Solved

VBA code for closing and opening form.

Posted on 2012-03-17
2
261 Views
Last Modified: 2012-10-07
Access 2007  (db attached for reference if needed)

I've been working this final issue with this db for over a month now, and I'm at the end of my ropes.  I was putting this together for my wife who works from home and was hoping to have it completed by our anniversary which is on the 1st of April.

Someone please help me.  I'm NOT an acces guru.  Most of this DB I've put together from snippets here and there and alot of help from outside sources, mainly here.



I currently have an Notinlist event on cboScreenName on form [Call Details] which opens [Client Details] and then upon the closing of [Client Details], the user is brought back to [Call Details] at which time the [Call Details] is not being refreshed properly with cboScreenName being updated with the added new name, so the user ends up continuously being re-asked if they want to add the new name to the db unless they close [Call Details] completely and then reopen it.

The problem with my NotinList event refreshing is that the contents [cboScreenName] is dependent on [cboCompanyName], and THAT combo box gets its contents from vba.  Anyhow, its a bit of a confusing interdependancy the way that everything works but it DOES work, and well, as I'd like it to.

So I guess what I'm looking for, is some sort of code that I can put on the onclick event of the close button on [Client Details] which will completely close [Call Details] and then re-open with selections pre-populated in cboCompanyName and cboScreenName based on cboCompanyName and txtScreenName on [Client Details].

cboClientName and cboScreenName both grab their contents based on cboCompany afterUpdate event though, so not only does cboCompanyName need to pre-populate with the contents of cboCompanyName from [Client Details] but done so in a way that the afterUpdate event code still runs as if the user manually selected the company name in cboCompanyName
Database.mdb
0
Comment
Question by:JARichard
  • 2
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37734015
Your DLookup syntax was incorrect.

The syntax should be:

DLookup("YourField", "YourTableOrQuery", "YourField---NotYourCombobox = '" & Something & "'")

The actual code should be:

    Result = DLookup("[Screen Name]", "tblClientInfo", _
             "[Screen Name]='" & NewData & "'")


(I replaced cboScreenName with [ScreenName])
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37734022
In other words you don't need to change your overall approach -- you just need to fix your DLookup statement in the Not In List event.

Please see JDettman's article here for a good explanation of DLookup and other domain functions:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_12-Dlookup-and-the-Domain-Functions.html
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Modal form 11 30
Object Variable or With Block Variable not set - Microsoft Access vba 3 34
Should I keep recordsets open? 3 24
2 IIF's in Access query 25 28
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

773 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