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

if then not working properly

Status
Not open for further replies.

Lightlancer

Programmer
Jul 18, 2008
88
NL
hi there,

strange thing just happend,

I have 2 fields:
Me.Test
&
Me.Serienummer

both contains the same value! (12345)

When i run this code
Code:
If Me.Serienummer = "gstrNummerserie" Then

gstrFactuurnummer = Me.Factuurnummer
gstrAanschafdatum = Me.Aanschafdatum
gstrGarantietijd = Me.Garantietijd
DoCmd.Close
MsgBox "Factuurnummer: " & gstrFactuurnummer & " behoort bij dit apparaat met serienummer: " & gstrSerienummer & " is toegevoegt aan de garantie regeling", vbOKOnly, "Garantie aangepast!"

Else
DoCmd.Close
MsgBox "Er is geen Factuur voor dit apparaat gevonden met serienummmer : " & gstrSerienummer & "", vbOKOnly, "Geen Factuur!"
End If

It just runs the Else code,
its like there never the same.... but when i remove the docmd.close from the code, so the form stays open, de 2 fields are the same (12345) and still its running the Else

the code is running in the On load event, i also tried it from on Open event, no luck......

Any ideas are welcome..


Lightlancer
 

You say that Me.Serienummer = 12345, how do you expext the

If part to run if you then say

If Me.Serienummer = "gstrNummerserie" Then

12345 is not "gstrNummerserie"

if gstrNummerserie is a field and the field equals 12345, then your code should read

If Me.Serienummer = gstrNummerserie Then

or

If Me.Serienummer = Me.gstrNummerserie Then

"gstrNummerserie" denotes a string/text, not a field name or a variable.




"gstrNummerserie" Then


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
i also tried to use
Code:
 if me.serienummer = me.test then
it also doesnt run
 

If Me.Serienummer = "gstrNummerserie" Then

It doesn't matter where the code is placed, unless

Me.Serienummer

equals the string

"gstrNummerserie"

the If part won't execute.




The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I meant of course for the version of the code where he compares me.serienummer = me.test.

I have a feeling we haven't heard the last of this, however.

Joe Schwarz
Custom Software Developer
 
solved the problem, created a query, and the query will filter on Serienummer. In condition of the query i put: getSerienummer()

then in the call back functions i put this

Function getSerienummer() blabla bla

getSerienummer = me.Serienummer

End function


This worked:D

Thanks for the tips and help!
 
How are ya Lightlancer . . .

I'm detecting a [blue]data typing[/blue] problem here. Try:
Code:
[blue]   If Me.Serienummer = Val(gstrNummerserie) Then
     [green]'or[/green]
   If Me.Serienummer = Val(Me!Test) Then[/blue]
[blue]Your Thoughts! . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top