Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emptying Combo box

Status
Not open for further replies.

JDU

Technical User
Dec 23, 2002
182
US
Upon choosing a value in a combo box, it opens a popup form. However when closing the popup I want the value in the combo box to disappear also rather than the value just chosen, how can I accomplish this.

Also is there a way to specifically position the popup on the screen.

Here is the code I am using. Thanks.

Private Sub LookItUp(strSQL)
Set dbs = CurrentDb()

'ignore error if query "qryEdit" doesn't exist.
On Error Resume Next
dbs.QueryDefs.Delete ("qryEdit")

On Error GoTo 0 'reset error checking

'create a query
Set qd = dbs.CreateQueryDef("qryEdit", strSQL)
End Sub

Private Sub cmboFullName_BeforeUpdate(Cancel As Integer)
strSQL = "Select * from tblMedStaff where Full_Name=" & Chr(34) & cmboFullName & Chr(34)

Call LookItUp(strSQL)

DoCmd.OpenForm "frmEdit", , , , , acDialog


End Sub
 
Try adding

me.cboname = null

I haven't failed, I have just found 10,000 ways that it won't work!
 
How are ya JDU . . . . .

If I read you correctly, you want to [purple]remove selected individual rows from a combobox.[/purple] Is this correct?

Can be done, but [blue]Row Count[/blue] is a serious consideration here.

If [blue]RowType[/blue] is [blue]Value List[/blue], there's a [purple]2k character limit[/purple] on the RowSource.

If [blue]RowType[/blue] is [blue]Query/SQL[/blue] then the [blue]Query/SQL[/blue] [purple]has to be dynamic via variable criteria.[/purple] Problem is, rejected rows would have to be Anded together and the [blue]limit for Ands in criteria is 40.[/blue] [purple]Hence you could only remove a max of 40 rows!.[/purple]

Consider this and let us know your prognosis . . .

Calvin.gif
See Ya! . . . . . .
 
Thanks TheAceMan1, but that's not what I was wanting, txaccess answered my question. That was good info though.

I do have another question though. I have a pop up form that comes up, is there anyway to position it on the screen where I want it to be and if so how do I do it. Thanks.
 
Take a look at the Move method of the Form object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
When I add this code, I get the error "Application defined or object defined error", how can I solve this. Thanks.

Private Sub Form_Load()
If Forms!frmEdit.Moveable Then
Forms!frmEdit.Move Left:=20, Top:=20
End If
End Sub
 
To move a form to a specific area you'll need to use the Windows api method apiMoveWindow along with apiGetParent. Hoever, you could use the MoveSize Method (kind of ugly because you will see the form move)
 
Thanks, I used MoveSize and it does the trick. I appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top