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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenForm - FILTER not working consistently 1

Status
Not open for further replies.

smsmail

Programmer
Aug 11, 2010
105
US
Hello

I am executing the following:
DoCmd.OpenForm "frmDownloadLog", , , "logid = " & Me.LogID

When the LOGID field is double clicked, the form should open with the appropiate record. Sometimes it does and sometimes it does not. The LOGID does exist and the record has valid data. Would anyone have any idea as to why the form is not consistently displaying the record.

Thanks so much in advance for your HELP.
 
maybe add
me.dirty = false

This will save any changes/updates to the form. If you type something in a textbox the changes do not get committed to the control until the after update event. So there is a period of time when the value of the control and the text are not the same.
 

Is the logid field text?
If so, try this...
Code:
DoCmd.OpenForm "frmDownloadLog",,,"logid = [b][red]'[/red][/b]" & Me.LogID [b][red]& "'"[/red][/b]


Randy
 
The field is numeric. I have tried both suggestions and I am getting the same results.

I have displayed the LOGID field in the program before it executes the OpenForm command and it displays correctly.

However, the form that is opened display the LOGID field as NULL.

Would you all know why I am loosing my data?
 
can you post the recordsource of frmDownloadlog?
 
The form that is executing the Openform command is a subform.

When the user double clicks the LOGID field, the frmDownloadLog is opened and that form's recordsource is a table, DOWNLOAD_LOG. The LOGID is the primary key.



 
One thing could be that the form is getting into a data entry mode. So you can only add a record. In the openform method set the data entry mode to acedit.
 
Dear MajP

I set the data entry mode to ACEDIT. It is working GREAT. Thanks so much!

I am new to Desktop Programming and VBA Access.

What is confusing me, why did it work sometimes and then did not other times? Please explain.

Thanks again.
 
It does not make sense to me, and it may be a sign of corruption. This is not expected behavior. It appears you are going into a data entry mode, but that is not the default. It is hard to say without seeing all of the code that calls the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top